Javascript to format date like mm/dd/yyyy hh:mm:ss

| April 26, 2010 | Reply

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;//January is 0!
var yyyy = today.getFullYear();
var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();
if(dd<10){dd=’0′+dd}
if(mm<10){mm=’0′+mm}
d=mm+’/’+dd+’/’+yyyy+’ ‘+hours+’:’+minutes+’:’+seconds

Tags: , , ,

Category: Uncategorized

About the Author ()