In Javascript, I have a datetime string that looks like:
2021-03-12 19:52:09
How do I convert it so it appears in this format?
03/12 12:34pm PST
Ideally I would like to do so without external libraries.
In Javascript, I have a datetime string that looks like:
2021-03-12 19:52:09
How do I convert it so it appears in this format?
03/12 12:34pm PST
Ideally I would like to do so without external libraries.
You could format it manually like this:
now = Date.now();
pst = new Date(now-(8*60*60*1000)); //-8 hours for pst
pst_str = `${pst.getMonth()}/${pst.getDate()} ${pst.getHours()%12}:${pst.getMinutes()}${pst.getHours()>=12?'pm':'am'} PST`;