Sequelize - dateonly vs date format

Viewed 2144

If I store timestamp 1625555827900 in 2 separate fields whose format are dateonly and date, will there be any difference?

1 Answers

You can not store the unix timestamps in both of the fields as their types are DATEONLY and DATE. Sequelize will through an error

DatabaseError [SequelizeDatabaseError]: date/time field value out of range: "1625555827900"

First you need to format the date like Tue Jul 06 2021 07:55:33 or 2021-07-06 07:55:33 in your code. In that case, it will save the complete date 2021-07-06 07:55:33.000000 for DATE field and skip the time part for DATEONLY field 2021-07-06.

Or you can use BIGINT instead if you are intended to store the unix timestamps.

Related