Quantcast
Channel: Adobe Community : Popular Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 14291

Why is there an offset when using DateConvert with DateCompare?

$
0
0

I'm developing on my local server and my current timezone is GMT +11 hours.

 

 

<cfset date1 = DateConvert("Local2UTC", now())>

<cfset date2 = '2014-03-06'> <!--- (Tomorrow at time of writing) --->

 

So, I was expecting that when I ran this code:

 

#DateCompare(date1,date2,'d' )#

that it would return a "-1" but it returned a "0" implying that the "day" was the same.

 

So, to double check I output:

DateConvert("Local2UTC", now())

grabbed its displayed value : {ts '2014-03-05 07:08:58'} and inserted that for comparison thus:
DateCompare("{ts '2014-03-05 07:08:58'}",date2,'d' ) and sure enough, it did return a "-1" reflecting that the day of date1 is indeed earlier than date 2.

 

 

Further investigation showed that  I had to add my timezone difference to date2 in hours thus:

 

<cfset date2 = '2014-03-06 11:00:00> to get

#DateCompare(date1,date2,'d' )#

 

to return a "-1".

 

 

 

Is this a bug or am I misinterpreting??


Viewing all articles
Browse latest Browse all 14291

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>