-1

I'm running a node shell on the terminal. Here is the output:

> new Date("2018-06-03T02:49:50.307Z");
2018-06-03T02:49:50.307Z
> Date("2018-06-03T02:49:50.307Z").getTime();
TypeError: Date(...).getTime is not a function
> var d = Date("2018-06-03T02:49:50.307Z");
undefined
> d
'Wed Sep 19 2018 11:17:07 GMT-0400 (EDT)'
> d.getTime();
TypeError: d.getTime is not a function
> d.getTime;
undefined
> d.getDate();
TypeError: d.getDate is not a function
> d
'Wed Sep 19 2018 11:17:07 GMT-0400 (EDT)'
>

As you can see, both getDate and getTime are not functions of the Date object. But other Stackoverflow Answers seem to imply that they should be, and doing a CTRL+F on the javascript docs reveals that this function is expected to exist.

The format for this time is the way Azure databases store datetimes. It looks like the Date object recognizes the format, since printing d returns a date.

jaredad7
  • 998
  • 2
  • 11
  • 33

1 Answers1

10

You're missing the new. So new Date("2018-06-03T02:49:50.307Z").getTime(); etc

cuzi
  • 978
  • 10
  • 21