Milliseconds to date converter
Converts a millisecond timestamp. The thirteen-digit kind `Date.now()` returns: into a date, and into every other epoch alongside.
How to use the milliseconds to date converter
JavaScript is the main source of these, and the mismatch with the rest of the world is a constant source of off-by-a-thousand bugs: Date.now() gives milliseconds while a database to_timestamp(), a Python time.time() and most APIs give seconds. Passing one where the other is expected does not error, it just produces a date in 1970 or in the far future, which is why it survives code review. If you are storing timestamps, pick one unit and be explicit in the column name. created_at_ms costs nothing and prevents the whole class of bug.
Questions
A choice made in 1995 and never revisited. Almost everything else uses seconds, which is the source of endless off-by-a-thousand bugs.
A millisecond value read as seconds. Dividing by a thousand somewhere, or multiplying, fixes it.
Multiply by 1000. The reverse is dividing, and rounding rather than truncating if precision matters.
No, everything here is UTC. Timestamps are stored in UTC precisely so they are unambiguous; converting to a local zone is a separate step and needs to know the zone.
Either, but be explicit about it in the column name. That single habit prevents the bug entirely.