These are my steps:
1 - Get Unix date from db
2 - Get browser timezone
3 - Convert unix time into timezone time
4 - Format into “MMM DD, YYYY @ HH:MM:SS”
My biggest issue is step 3. When I use toLocaleString("en-US", {timeZone: tz}) (timezone being previously defined), the time string is converted into a non-Unix string: "Sat Sep 05 2020 21:44:53 GMT-0700"
Is there any way I can back-convert this into a UNIX string? I can’t chain together all of the manipulations… any help would be appreciated!
Hi @CarlyRaeJepsenStan!
Just use @Anish’s code to do everything you need and convert the Unix from the DB to the local timezone, not just convert from Date to Unix timestamp
Hmmmm…
I did a little bit more research and i found this: https://momentjs.com/timezone/
It comes with moment.format() pre-installed which is nice.
Could work client-side with unpkg and a little magic
Finally got it to work!
var moment = require("moment-timezone")
var june = moment(1599451463030).format();
console.log(june)
var asdf = moment(june.toString())
asdf.tz('America/Los_Angeles').format('ha z')