Ask Your Question
0

Timestamp appears to be incorrect

asked 2019-05-08 16:01:37 -0500

metadaddy gravatar image

updated 2019-05-08 16:04:18 -0500

I am using time:createDateFromStringTZ(<string>, <time zone>, <date format>), which accepts a datetime string and outputs a date object. But when I use the input timestamp string 01312019 00:00:00 the output DATETIME timestamp is Jan 30, 2019, 11:00:00 PM.

I am located in the mountain time zone, I am using "America/New_York" as the timezone in time:createDateFromStringTZ, the ui.server.timezone in the Data Collector Configuration is set to MDT, and the SDC machine's time zone is also MDT.

How can I ensure that the input time string and the output datetime object have the same hours, minutes and seconds ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-05-08 16:03:41 -0500

metadaddy gravatar image

This is expected. You are reading data from the Eastern Standard time zone (GMT -5 hours), and viewing it in Mountain Daylight Time (GMT -6 hours). The underlying datetime value is correct (it's the number of milliseconds since 1/1/1970 UTC), but any string representation (including in the UI) will vary according to the time zone in force.

If you're turning the DATE object back into a string, you will have to ensure that you include time zone information in the conversion.

For example, I'm currently in the Pacific time zone. If I use your input data, and the following expressions:

image description

I see:

image description

Which is completely as expected, for the above reasons.

If it's being sent to a database, again, the underlying data should be correct, but what you see might vary according to the database's timezone.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-05-08 16:01:37 -0500

Seen: 105 times

Last updated: May 08