Possible Duplicate:
How to get current date in JavaScript
I need to get todays date in the format yyyymmdd using JavaScript.
I've used the following code:
var d = new Date();
d.getFullYear()+ '' +((d.getMonth()+1)) + '' + d.getDate();
But the month and date are returned in single digits, does someone know how to do this?
var d = new Date();
var df = d.getFullYear()
+ ('0' + String(d.getMonth()+1)).substr(-2)
+ ('0' + String(d.getDate())).substr(-2);
alert(df);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With