Help with CET datetime as object using moment()

Gold is to register Central European Time (CET ) when creating or updating date to db.

DB only support datetime as Object and not string.

This is saved to DB but the time is wrong.
image

This is not saved to DB but the time is correct.
image

Using MySQL to store data.

How can I register current time?

-Thore

What you are experiencing is implict string conversion of the date object as well as the fact moment works on UTC.

CET is UTC+1 so you should be able to do this to get what you want?

const date = moment().add(1, 'hour').toISOString();

Moment Docs for .toISOstring()

2 Likes