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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

why does Date.parse(dateString) return NaN in code of service?

jbai
1-Newbie

why does Date.parse(dateString) return NaN in code of service?

paste piece of my code below

>>

var start = Date.parse('2015-12-23 12:00:00');

var end = Date.parse('2015-12-23 13:00:00');

what i got was that both start and end equal to NaN, is there anything wrong with the code?

4 REPLIES 4
qn
1-Newbie
1-Newbie
(To:jbai)

Try

Date.parse('2015-12-23T12:00:00');

https://repl.it/BaRj/

Documentation: search for "ECMAScript 5 ISO-8601 format support"

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse

jbai
1-Newbie
(To:qn)

Thank you for your answer! I tried it but it made no difference. it seems like javascript Date object in thingworx works differently as normal?

qn
1-Newbie
1-Newbie
(To:jbai)

In fact, in thingworx it's

Date.parse('12/23/2015 12:00:00')


or


Date.parse("23/12/2015 12:00:00 GMT+0100")


Case related: https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS225991

This is an in-built date functions parseDate and parseDateISO. Did you tried that?

Top Tags