Copy link to clipboard
Copied
Has anyone encountered this issue before,
<cfset strDateTime = DateFormat(DateAdd( "s", GetTimeZoneInfo().UTCTotalOffset, Now()),"yyyy-mm-dd HH:mm:ss")>
<cfset TestDate = DateAdd( "s", GetTimeZoneInfo().UTCTotalOffset, Now())>
Output
=============================================
Date1 = {ts '2010-02-05 22:21:54'}
Date2 = 2010-02-05 22:02:54
How come the output for minutes stays the same on #strDateTime# everytime i run it?
Copy link to clipboard
Copied
"yyyy-mm-dd HH:mm:ss")>
The DateFormat() masks do not have a "minutes" portion. So the "m" is actually returning the month not minutes. You have to use DateFormat() + TimeFormat().
Copy link to clipboard
Copied
Thanks you all for your help, that was exactly the problem, now its fixed!!!
Copy link to clipboard
Copied
Because DATEformat() is for formatting dates, not times. "mm" as far as dateFormat() is concerned means "month".
You need to use TIMEformat() to format times.
--
Adam
Copy link to clipboard
Copied
A lot of people make this mistake because DateFormat() confusingly allows the hours and seconds portions. But yes, DateFormat really does not format times. So as mentioned, you have to use two separate functions to handle the date and time.