Skip to main content
roldeguz
Participant
September 18, 2018
Question

DateTimeFormat returns different results in CF2016 and 2018

  • September 18, 2018
  • 3 replies
  • 568 views

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 has been closed for replies.

3 replies

Sandip_halder
Community Manager
Community Manager
September 24, 2018

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

Inspiring
September 22, 2018

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

roldeguz
roldeguzAuthor
Participant
September 24, 2018

Hi,

Have you tried it on both CF 2016 and CF2018?

BKBK
Community Expert
Community Expert
September 18, 2018

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

roldeguz
roldeguzAuthor
Participant
September 18, 2018

Hi,

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

Thanks!

BKBK
Community Expert
Community Expert
September 18, 2018

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")