I have a script that prints the current date and time in JavaScript, but the DATE
is allways wrong. Here is the code:
var currentdate = new Date();
var datetime = "Last Sync: " + currentdate.getDay() + "/"+currentdate.getMonth()
+ "/" + currentdate.getFullYear() + " @ "
+ currentdate.getHours() + ":"
+ currentdate.getMinutes() + ":" + currentdate.getSeconds();
It should print 18/04/2012 15:07:33
and prints 3/3/2012 15:07:33
Any help? Thanks
Just use:
If you want true mysql style date time use this
2013/10/04 08:51:32
Change
.getDay()
method to.GetDate()
and add one to month, because it counts months from 0.get current date and time