I have a Mariadb table (server is my Raspberry Pi in the UK, system time is default, currently BST)
create table foo (created datetime default now(), mydate datetime);
and Node-Red creates a record via the mysql node.
var date1 = new Date().toISOString().slice(0, 19).replace('T', ' ');
msg.topic = "INSERT INTO foo (mydate) VALUES ( '" + date1 + "')";
After running the flow at 18:25 BST, the record is created like this:
created 2021-06-13 18:25:16 mydate 2021-06-13 17:25:16
(the database generated field is in BST, the field I specified is in UTC)
This messes up my calculations of the difference between a stored date and now()
I have read "Store datetimes as UTC", which seems to be what Node-Red is doing but how to make now() do the same thing?
Mariadb's global variable time_zone is "SYSTEM" and it will not let me change it to "GMT" or "UTC"