Correcting UTC timings when saving to MariaDB

Viewed 22

I am having a bit of a problem when saving times/dates to MariaDB. Because of the UTC format that dates and times are saved it can save times 1 hour behind and dates can be saved as the previous day.

Most of the work arounds I have seen, involve pulling the data back from the DB and converting it, however I was keen to save it to the DB with the correct dates/times already entered.

I done this using {{moment.utc("Date_Entry").tz("Europe/London").format()}}

The problem I have at the minute, though, is... If I want to leave the date/time empty, the function above saves the current date/time.

Ideally I would like to handler the UTC conversion if required, but if the entry is empty, save a NULL value to the DB

Does anyone know of a better solution than what I have currently?

0 Answers
Related