For some project tasks, I need to reduce the date entered by the user by three hours to get GMT.
I do it like this:
var GMTTimeShift=3; var fdate=document.getElementById("fd1").value.split('-'); var d1=new Date(); d1.setFullYear( fdate[2],parseInt(fdate[1])-1,fdate[0] ); d1.setHours(parseInt(document.getElementById("ft1").value), parseInt(document.getElementById("ft2").value)); parseInt(document.getElementById("ft2").value)); var a=d1.getTime()-GMTTimeShift*3600000; d1.setTime(a); console.log(d1);
Accordingly, there are three input fields in which the time is entered: the hour of the minute is the date with hyphens, for example
00 00 01-08-2012
So here.
When going from month to month, namely, on August 1 and September 1, I catch a strange glitch - we do not get 21:00 07-30-07, but 21 00 30-11-2011 21:00
in the remaining months, the correction is true. Tell me, please, the reason for this behavior.