asp classic - Convert Time to UTC vbScript -
i have next function fine @ converting current time utc time.
function toutc(byval ddate) dim oshell : set oshell = createobject("wscript.shell") toutc = dateadd("n", oshell.regread("hkey_local_machine\system\currentcontrolset\control\timezoneinformation\activetimebias"), cdate(ddate)) end function
however, thinking not adequately handle conversion of future or historical dates utc, since function need know offset of server's timezone @ time of date beingness converted, , whether or not during daylight savings time or not.
how can around this?
i using vbscript/classic asp on windows server iis7.5
to clarify, has nil formatting date. converting utc server timezone historical dates. during daylight savings time, offset off 60 minutes if seek convert datetime occurred in standard time)
for example: lets today, 2013-02-19 (non daylight-savings time), want covert timestamp say, 2008-06-05 (during daylight savings period) pdt (my server timezone) utc. using method in function give me value 60 minutes off right value (because current time pst (not pdt), offset wrong historical date).
here solution ended implementing @ suggestion of @aardvark71.
i set in func.asp file:
<script language="javascript" runat="server"> function toutcstring(d) { var ddate = new date(d); homecoming math.round(ddate.gettime() / 1000); }; </script>
it outputs timestamp value. anywhere in classic asp code, can this:
response.write dateadd("s", toutcstring(cdate("11/11/2012 06:25 pm")), "01/01/1970 00:00:00") 'expect 11/11/2012 10:25:00 pm gmt/utc time response.write dateadd("s", toutcstring(cdate("06/11/2012 06:25 pm")), "01/01/1970 00:00:00") 'expect 6/11/2012 9:25:00 pm gmt/utc time
this (i believe) simple, , produces expected values , factors in dst.
asp-classic vbscript utc
No comments:
Post a Comment