#2571·mysql

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

Author: coolaj86Created Jul 11, 2025Updated Sep 9, 2025

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.