Skip to main content
1-Visitor
December 23, 2015
Question

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

  • December 23, 2015
  • 3 replies
  • 8928 views

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?

3 replies

1-Visitor
December 23, 2015

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

jbai1-VisitorAuthor
1-Visitor
December 25, 2015

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?

1-Visitor
December 28, 2015

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

1-Visitor
March 11, 2016

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