Page 1 of 1

NewDateFormatter

Posted: Mon Mar 31, 2014 2:51 pm
by Wim Gielis
Hi all

I found 3 interesting new functions in the Reference Guide 10.2: NewDateFormatter, FormatDate, ParseDate.

Useful stuff!
However, I get wrong results, it seems, or I am interpreting the results the wrong way.

In the Prolog tab, since I'm based in Brussels (Belgium):

Code: Select all

i = NewDateFormatter('nl_BE', 'Europe/Brussels', 'serial', 'long', 'datetime');
now_formatted = FormatDate( now, 'HH:mm:ss' );
AsciiOutput('test.txt', now_formatted);
The result is 18:48 for me currently in Belgium it is 16:48 (4:48 PM).

Hence, 2 hours of difference.

if I use:

Code: Select all

i = NewDateFormatter('nl_BE', 'Etc/UTC', 'serial', 'long', 'datetime');
I get the correct result but this is not how the function should be used, is it?

See http://en.wikipedia.org/wiki/List_of_tz ... time_zones for time zones.

Did anyone use the function?

Wim

Re: NewDateFormatter

Posted: Mon Mar 31, 2014 6:00 pm
by dr.nybble
The TM1 function NOW returns a value that is interpreted as UTC time.
So you need to pass 'Etc/UTC' as the timezone when formatting it.

Passing a different timezone would be useful if, for example, you were parsing timestamps that were not UTC but a local time.

Re: NewDateFormatter

Posted: Mon Mar 31, 2014 6:22 pm
by Wim Gielis
Thank you for the reply, that makes sense.