0

I've seen this post already, and it didn't quite shed much light on what is going on.

I have a mongo server, that stores information about classes, what times and days they meet and what not. I also have an express server, that interacts with and returns this data.

When I look at the data in Robo3T (a mongo data viewer), it is formatted - as it should be - like so: 2018-09-07 04:00:00.000Z But when the data comes back to the server, it comes back like this: 2018-09-07T04:00:00.000Z

What is causing this? In no way do i make any attempt to format this data before I display it. I also checked the server output, which returns it the same way:

startDate: 2018-09-07T04:00:00.000Z

I guess my question is, why is this happening? and is this impacting my ability to query results from mongo based on a date range? Any assistance would be much appreciated, thank you.

Ian Fabs
  • 97
  • 4
  • 11
  • 1
    "In no way do i make any attempt to format this data before I display it" - That's the issue then. Every tool you use to inspect the piece of data applies its own format. – Álvaro González Aug 11 '18 at 17:25

1 Answers1

1

Robo 3T just happens to display dates that way. This does not mean that it actually is stored that way. When you switch the view to "text mode", you will see that it actually is ISODate("2018-09-07T04:00:00.000Z") (with the T).

This format is actually the date format string that is used in JavaScript. And yes, the T is required. See What are valid Date Time Strings in JavaScript?

str
  • 42,689
  • 17
  • 109
  • 127