Question
DateDiff problem
I'm trying to convert the current time, (or any time come to
that), into an Epoch time or timestamp. The steps I use are first
to convert to UTC, and then get the DateDiff in seconds from
1/1/1970 00:00:00. However, the result is off by exactly 3600/1
hour and I don't know why. If I do the conversion the other way,
(epoch to date), I also get the hour difference problem. I don't
see how DST could be the problem as I'm converting to UTC first,
(and I've confirmed that the UTC is correct).
Here's my code:
<cfset info = GetTimeZoneInfo()>
<cfset utcDateTime = DateAdd("s", info.utcTotalOffset, Now())>
<cfset epochDate = CreateDate(1970, 1, 1)>
<cfset epochTime = DateDiff("s", epochDate, utcDateTime)>
When I confirm the output of epochTime with an online service such as www.epochconverter.com it's short by exactly 3600, even though the UTC date is correct. Can someone help, and maybe run the above code on a server in there locale to see if they experience the same issue?
Thanks!
Here's my code:
<cfset info = GetTimeZoneInfo()>
<cfset utcDateTime = DateAdd("s", info.utcTotalOffset, Now())>
<cfset epochDate = CreateDate(1970, 1, 1)>
<cfset epochTime = DateDiff("s", epochDate, utcDateTime)>
When I confirm the output of epochTime with an online service such as www.epochconverter.com it's short by exactly 3600, even though the UTC date is correct. Can someone help, and maybe run the above code on a server in there locale to see if they experience the same issue?
Thanks!
