DateConvert() vs DateAdd() inconsistency question
I am working on some Date Helper functions where I need to convert UTC dates to unixtimestamps and vice versa. Interestingly I came across an inconsistency using the DateConvert function in cooperation with DateDiff in that the timestamps are different. DateConvert makes the timestamp using local time while DateAdd uses the appropriate UTC Date. I was wondering if this is a bug / anomaly or my misunderstanding how DateConvert works in ColdFusion.
The following is syntax to reproduce scenario
<cfset unixEpoch = CreateDate(1970,1,1) />
<cfoutput>
<pre>
Local Date: #Now()# [CORRECT]
UTC Date: #DateConvert("local2Utc", now())# [CORRECT]
=======================================================
UTC to Unix Timestamp Conversion
=======================================================
UTX (DateConvert): #DateDiff("s", unixEpoch, DateConvert("local2Utc", now()))# [WRONG]
UTX (DateAdd): #DateDiff("s", unixEpoch, DateAdd( "s", GetTimeZoneInfo().UTCTotalOffset, now() ) )# [CORRECT]
</pre>
</cfoutput>
The following is what the above unit of code output last time I ran it
Local Date: {ts '2015-12-30 10:44:25'} [CORRECT]
UTC Date: {ts '2015-12-30 18:44:25'} [CORRECT]
=======================================================
UTC to Unix Timestamp Conversion
=======================================================
UTX (DateConvert): 1451472265 [WRONG]
UTX (DateAdd): 1451501065 [CORRECT]
*** Use http://www.unixtimestamp.com/index.php to confirm unix timestamp discrepancies
Any thoughts would certainly be helpful -- Thank you
