cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Javascript Date object initialised from a string

khayes1
13-Aquamarine

Javascript Date object initialised from a string

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.

1 ACCEPTED SOLUTION

Accepted Solutions
jamesm1
5-Regular Member
(To:khayes1)

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

View solution in original post

2 REPLIES 2
jamesm1
5-Regular Member
(To:khayes1)

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

khayes1
13-Aquamarine
(To:jamesm1)

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

Appreciate your effort.

Kieron

Top Tags