Anomaly inserting current_timestamp() into MariaDB table

Issue

I’m writing a program using Golang (1.17.8), storing information in a MariaDB (10.6.5) database. I often need to store a created_at field inserted as current_timestamp() which is pretty common.
My system time is UTC +1.00 (BST) and I’m working with Windows 10 (21H1)
MariaDB is set to use system time and from the command line both SELECT NOW() and SELECT CURRENT_TIMESTAMP() output exactly that.
Logging the output of the Golang function time.Now() also gives system time.
If I insert time.Now() from my program into my MariaDB table it is inserted as UTC
Perhaps a simple reason exists for this but I do not know why. I have not ever used a different timezone and as mentioned, MariaDB reports it is using system time anyhow.
How can I change this please ?

Solution

As the documentation states, this is normal behavior in the absence of a timezone. Which time zone would you wish to use in your output?

Is your server in the UTC timezone by any chance?

Answered By – Sangam

Answer Checked By – Robin (GoLangFix Admin)

Leave a Reply

Your email address will not be published.