Just curious about TIME

Hi there! Anyone from MongoUniversity or fellow classmates can help me understand the difference between those two different formats the time has been saved in the movie collection. I can see one is ISO the other is a string, I would like to know what is the difference and under which circumstances I should use one instead of another.

Here is a screenshot

Hi @pitrens,

The lastupdated field is of type string and tomatoes.lastUpdated field is of type date.
You can verify the same by running following commands in the terminal:

Please refer to the following documentation links for more details:

Please let me know if you have any questions.

Thanks,
Sonali

Thank you for the reply. Yes, I have checked the documentation and also mentioned that in the original question. My real query is, Is there any reason to use one over another to manipulate date? or Why in this dataset the Mongo team use both? Is it to show us there are alternative or something else?

Thank you!

Hi @pitrens,

Let me confirm this with our course owners and get back to you regarding the same.

Please let me know if you have any questions.

Thanks,
Sonali

Hi @pitrens,

The two formats (Date type and string) are in the collection to show that both options are available.

If you want to work with dates in your queries or aggregations, the integer format is better. The date format measures represents the date since the Unix Epoch. Computationally this is easier to work with.

However, if you import data with dates in string format MongoDB can still support this. MongoDB is flexible enough to handle both types. If you are just presenting the dates back to the client it is fine to have them in string format.

Please also refer to the following operators that allows you to convert dates:

Please let me know if you have any questions.

Thanks,
Sonali