How to get current date in javascript?
Date() is a feature of javascript. Check the full date feature here.
var d = new Date();
var month = d.getMonth()+1;
var day = d.getDate();
var output = d.getFullYear() + '/' + (month<10 ? '0' : '') + month + '/' +
(day<10 ? '0' : '') + day;
console.log(output);
Date objects are created with the new Date()
constructor.
By default, JavaScript will use the browser’s time zone and display a date as a full text string:
for eg:- Tue Dec 29 2020 23:07:27 GMT+0530 (India Standard Time)
d.getMonth() returns current month as a number from 0-11 that’s why +1 added to month.
For more date functions click here.
Hi! Someone in my Myspace group shared this site with us so I came to check it out.
I’m definitely loving the information. I’m bookmarking and will be tweeting
this to my followers! Superb blog and brilliant design.
Stop by my web site; software akuntansi
Thank you