Skip to main content
roldeguz
Participant
Sep 18, 2018 6:08 PM UTC
Question

DateTimeFormat returns different results in CF2016 and 2018

I am using GetHttpTimeString() function to get the current date and time in UTC/GMT. But when I format it using DateTimeFormat, its returning different results:

In CF2016, when I do this:

<cfdump var="#GetHttpTimeString()#">

<cfdump var="#DateTimeFormat(GetHttpTimeString(), "yyyy-mm-dd HH:nn:ss")#">

it will return:

Tue, 18 Sep 2018 17:44:27 GMT --> UTC

2018-09-18 17:44:27 --> still in UTC

In CF2018, when I do this:

<cfdump var="#GetHttpTimeString()#">

<cfdump var="#DateTimeFormat(GetHttpTimeString(), "yyyy-mm-dd HH:nn:ss")#">

it will return:

Tue, 18 Sep 2018 17:44:27 GMT --> UTC

2018-09-18 12:44:27 --> current date/time in my timezone

Unless I pass a third argument for the timezone, it will use the server's timezone by default.

Is this an intentional change, if it is, I can't find anything in the 2018 Release Notes.

Thank you!

Ollie de Guzman

This topic is closed to new replies. Start a new post to keep the conversation going.

8 replies

Sandip_halder
Participating Frequently
Sep 24, 2018 4:30 PM UTC

Can you send me an email at cf.install@adobe.com so that we can get together and look into this issue?

Translate
Inspiring
Sep 22, 2018 11:09 PM UTC

I don't see this behaviour when I look at your sample code on trycf: https://trycf.com/scratch-pad/gist/8c4cc8f8aad9d648091b61f37951e25b

Translate
roldeguz
roldeguzAuthor
Participant
Sep 24, 2018 1:14 PM UTC

Hi,

Have you tried it on both CF 2016 and CF2018?

Translate
BKBK
Community Expert
Community Expert
Sep 18, 2018 7:43 PM UTC

The problem might be that you're not passing an argument to the function getHttpTimeString(). Do something like getHttpTimeString(now()).

Translate
roldeguz
roldeguzAuthor
Participant
Sep 18, 2018 7:50 PM UTC

Hi,

I tried adding Now() as an argument to the getHttpTimeString() function, I am still getting the same results from my OP.

Thanks!

Translate
BKBK
Community Expert
Community Expert
Sep 18, 2018 8:31 PM UTC

roldeguz  wrote

Hi,

I tried adding Now() as an argument to the getHttpTimeString() function, I am still getting the same results from my OP.

Then perhaps it's because getHttpTimeString(now()) returns a string, whereas dateTimeFormat() requires a datetime object. So your next try is

dateTimeFormat(parseDatetime(getHttpTimeString(now())), "yyyy-mm-dd HH:nn:ss")

Translate