8:53 PM PDT - basically 12hrs format with AM/PM. Irrespective of machine time format.
Asked
Active
Viewed 56 times
-3
-
What part of this are you having trouble with? Just get the hours, check if it's greater than 12. If it is, subtract 12 and change to PM. – Barmar Sep 22 '17 at 03:58
-
You could also use the moment.js library, it has a time formatting function. – Barmar Sep 22 '17 at 03:59
-
1The question is: [Where can I find documentation on formatting a date in JavaScript?](https://stackoverflow.com/q/1056728/1169519) – Teemu Sep 22 '17 at 04:08
1 Answers
2
I suggest using moment Timezone: http://momentjs.com/timezone/
then it's as simple as
moment().tz('PDT').format('hh:mm A z')

VDog
- 1,083
- 2
- 13
- 35
-
-
Yes, https://stackoverflow.com/questions/18229022/how-to-show-current-time-in-javascript-in-the-format-hhmmss just remove the ss part in that function, and add a hardcoded value of PDT in the return... – VDog Sep 22 '17 at 05:32