Skip to main content
1-Visitor
October 6, 2017
Solved

Javascript Date object initialised from a string

  • October 6, 2017
  • 1 reply
  • 2914 views

Hi,

I'm trying to create a JS Date object from a time string which is passed from the edge on my remote assets.

The string has the format 2016-Oct-06 09:41:23 +00:00:00​. I have tried a number of ways to initialise a date object with this string, but none of them seem to work.

Would anyone know how I might do this?

Thanks.

Best answer by jamesm1

Thingworx snippets use the Joda Datetime Format, so you can use the following parseDate snippet:

var result = parseDate("2016-Oct-06 09:41:23 +00:00:00", "yyyy-MMM-dd HH:mm:ss Z");

1 reply

jamesm15-Regular MemberAnswer
5-Regular Member
October 7, 2017

Thingworx snippets use the Joda Datetime Format, so you can use the following parseDate snippet:

var result = parseDate("2016-Oct-06 09:41:23 +00:00:00", "yyyy-MMM-dd HH:mm:ss Z");

khayes11-VisitorAuthor
1-Visitor
October 8, 2017

Thanks James, that's what I was looking for.

Appreciate your effort.

Kieron