function getMyTime(){ var mydate = new Date(); var y = mydate.getFullYear(); var m = mydate.getMonth()+1; var d = mydate.getDate(); var h = mydate.getHours(); var f = mydate.getMinutes(); if(f<10){ f = '0'+f; } var s = mydate.getSeconds(); if(s<10){ s = '0'+s; } return y+'/'+m+'/'+d+' '+h+':'+f+':'+s; } myTime = getMyTime(); alert(myTime)