I have simple script:
function test(time) {
var dt = new Date( time * 1000 )
var sec = dt.getSeconds()
if ( sec < 10 ) sec = "0" + sec
var min = dt.getMinutes()
if ( min < 10 ) min = "0" + min
var hour = dt.getHours()
if ( hour < 10 ) hour = "0" + hour
var time = hour + ":" + min + ":" + sec
return time
expected resut (test(1800) ) : 30:00, but I have result: 04:30:00. Can you help me correct this script ?
My timezone GMT+04
The answer is very simple:
The constructor of
Dateobject can accept an:While
Date.get*functions return using local timezone.If you really need to, use
Date.getUTC*instead.