I
I
Ivan Yudin2015-03-15 14:21:33
JavaScript
Ivan Yudin, 2015-03-15 14:21:33

How to store date without time in MongoDB?

The task is trivial - storing exchange rates in the database, public API.
Question - how to store and how to issue a date (DB - Mongo, platform - node.js)?
Initially, I made the Date type and simply set the time to 00:00:00.
But, the time is stored in UTC, and it is also issued: {"currency":"CBR-USDRUB","value":61.3167,"date":"2015-03-15T00:00:00.000Z"}
But, if the data is requested someone from Cape Verde (UTC-1), then in his timezone will receive the date 2015-03-14 and decide that the course is for this number?
How to make it work is understandable (for example, store the date as a string in the form "2015-03-15", or convert to UTC on the client side), the question is how to do it correctly and beautifully?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fireproof Cockroach, 2015-03-16
@uonick

And what prevents to store in INT (unixtime) and form any format during the output?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question