How do I know if I have to use NOW or NOW_UTC when inserting current time into a database row?
I’m using NodeJS, MariaDB and PostgreSQL
How do I know if I have to use NOW or NOW_UTC when inserting current time into a database row?
I’m using NodeJS, MariaDB and PostgreSQL
NOW gives you time based on your server locale.
NOW_UTC gives time based on universal time constant otherwise known as Greenwich mean time where time offset is zero.
On top of Brian's reply, just to be clear NOW gives you local server time/date not the user time/date.
Yes, really should have said server locale, that's really important
and how does one get the user time?
Hi jimed99,
There are two methods:
datetime component on the front end and submit that along with the other form information.Another option is using the IP and look for an API that retrieves the data, for example:
Time Zone America/Argentina/Buenos_Aires (-0300)
So you do UTC - 03 hs and get the time of the user
I vaguely remember talks about database driver configuration and time, and people were experiencing unexpected times, that was the source of my question
Thinking of this?