function getCurrentDateTime() {
var currentDate = new Date();
var dd = currentDate.getDate();
var mm = currentDate.getMonth()+1; //January is 0!
var hh = currentDate.getHours();
var min = currentDate.getMinutes();
var ss = currentDate.getSeconds();
if(dd<10){
dd='0'+dd;
}
if(mm<10){
mm='0'+mm;
}
if(hh<10){
hh='0'+hh;
}
if(min<10){
min='0'+min;
}
if(ss<10){
ss='0'+ss;
}
var datetime = currentDate.getFullYear() + "-" + mm + "-" + dd + " "+ hh + ":" + min + ":" + ss;
return datetime;
}
No comments:
Post a Comment