I've a problem related to timezones.
We are saving logs in our app but we have to show the date in a local date time.
So, for example:
User A saved a log and the database registered this: 2020-09-23T20:22:18.7926625
If I transform that time, it is 8:22 (1 hour above mine), what should I do to transform that date to my current time zone, so it can be desplayed as 7:22
Date()or with a library like moment.js as @chewie suggested. Basically you want the time to always be in UTC (or preferred standard) in the DB and convert it to the local time zone wherever it may be displayed.SELECT UNIX_TIMESTAMP(timestamp)*1000 WHERE conditionand pass that to JavaScriptnew Date(here). Just make sure you have your time set correctly on the Server. Sometimes you don't have access to the Server time. In those cases (at least in PHP) you can usedate_default_timezone_set('America/Vancouver');before any headers are sent, then INSERT with prepared statements usingtime(), which must be bound to a variable.