0

I am using moment for manipulate date in my application (NodeJs).

At this time, i have a client who send a date in the serveur like this 2018-04-17T12:47:12.123+01:00 and the serveur transform it to into start of day of timezone.

moment("2018-04-17T12:47:12.123+01:00").startOf('day').format();

Who return : 2018-04-17T00:00:00+02:00

And after it convert it into utc :moment.utc("2018-04-17T00:00:00+02:00").toISOString()

And give me : 2018-04-16T22:00:00.000Z.

I want to know if it's a good practice to format always date on start of day ? I do this because i don't care about hours, i need only the day.

Thx

johan pujol
  • 173
  • 2
  • 10

1 Answers1

0

When you don't care about the time, I'd say it's good practise to save storage space and store as "date" instead of "datetime".

Moreover, it also prevents any future confusion since no questions can be asked about the time.

Fierr
  • 185
  • 2
  • 10