11-Apr-2023
.
Admin
Hi Guys,
In this example,I will learn you how to get current date in moment js.you can easy and simply get current date in moment js.
Here is a very simple example of how to get current date using jquery moment js. i will show you some moment method that getting current date.
Let's see simple example with output:
Example:
<!DOCTYPE html>
<html>
<head>
<title>JQuery Moment js Example - Nicesnippets.com</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" crossorigin="anonymous"></script>
</head>
<body>
<h1>JQuery Moment Get Current Date Example - Nicesnippets.com</h1>
</body>
<script type="text/javascript">
var currentDate1 = moment();
console.log('Current Date 1: ' + currentDate1);
var currentDate2 = moment().format();
console.log('Current Date 2: ' + currentDate2);
var currentDate3 = moment().format('MM/DD/YYYY');
console.log('Current Date 3: ' + currentDate3);
var currentDate4 = moment().unix();
console.log('Current Date 4: ' + currentDate4);
var currentDate5 = moment().toISOString();
console.log('Current Date 5: ' + currentDate5);
</script>
</html>
Output :
Current Date 1: 1623388798891
Current Date 2: 2021-06-11T10:49:58+05:30
Current Date 3: 06/11/2021
Current Date 4: 1623388798
Current Date 5: 2021-06-11T05:19:58.893Z
It will help you...
#Jquery