We have a project I'm working on internally that will allow me to set up servers however I would like and I'm using this as an opportunity to test and learn things at a deeper level. I know I'm super weak on time zones and their interaction with databases and Ignition/JDBC, so I'm using this to get things right and understand how time is stored in a database and then pulled through JDBC/Ignition so that they show properly to the client.
I know I can use Postgresql and much of this goes away, however, I want to make sure that I understand how things work so I can support existing and new systems that aren't so friendly to playing around.
I've got the different servers setup like this:
MariaDB running on Ubuntu. MariaDB timezone is set for System, and the OS is set for Etc/UTC.
Ignition 8.1.36 running on Windows, where the OS is set for EST.
I have a simple table to test creating new rows and inserting timestamps from different locations, and I'm not getting a consistent timestamp back.
The table is:
CREATE TABLE `tbltest` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ts_client_insert` timestamp NULL DEFAULT NULL,
`ts_current_timestamp` timestamp NULL DEFAULT current_timestamp(),
`note` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
When new records are created, the ts_current_timestamp field is generated with the current_timestamp from the MariaDB server and the time is correct according to UTC. However when reading that data into Ignition, or dBeaver, that column isn't converted from the UTC time to the time zone of client or gateway.
If I insert data from Ignition into the ts_client_insert column using the system.date.now() function, then that data is properly timezone adjusted if I change the client time zone. However, when looking at the column values, which I would assume to be the same or close they aren't.
In reading it seems that the timestamp column internally holds everything as UTC. If that is the case, then why when I insert data through JDBC that value doesn't match the current_timestamp value from the database? Do I have a configuration wrong somewhere? Is this a functional misunderstanding from my end (most likely lol)?