Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • What if the number is negative? Commented Nov 24, 2011 at 18:26
  • it shouldn't be because it really does represent a date from the system Commented Nov 24, 2011 at 18:29
  • @TruMan1 - Any date before 1969 has a negative serial number in JavaScript. Commented Nov 24, 2011 at 18:36
  • didn't know about that backreference before @gilly3: /(\-?\d+)/.test(str) ? new Date(+RegExp.$1) : null; Commented Nov 25, 2011 at 7:46
  • 1
    The answer given here is faster, since it doesn't require regex parsing: stackoverflow.com/a/2316066/163227 Commented Jan 18, 2017 at 19:22