mysql icon indicating copy to clipboard operation
mysql copied to clipboard

Setting incorrect value for `timestamp` causes date to be set as UTC and to return as a string

Open coolaj86 opened this issue 1 year ago • 1 comments

I had accidentally set { "timestamp": "America/Denver" } and I would get back MySQL strings instead of JavaScript Dates.

I would have expected

  • an exception - bad values should throw errors
  • or the default to be used - bad values could also be ignored, and the default used

What I got was

  • inserted values would be transposed - as if the UTC hours value was used, but set as if it were local
  • selected values would return as strings - rather than returning as date objects

The solution was to use { "timestamp": "local" }.

As far as I can tell { "timestamp": "UTC" } and { "timestamp": "-06:00" } had no effect.

coolaj86 avatar Jul 11 '25 22:07 coolaj86

The driver doesn’t validate the option strictly, it treats unknown values as “don’t parse dates,” so it just returns strings. That’s why you didn’t see an error, just strange behavior.

adjetey0 avatar Sep 09 '25 12:09 adjetey0