I have date strings like Sun May 10 2020 13:00:00 GMT-0800 (Pacific Standard Time)
and 2020/05/10 13:00:00
. I would like to retrieve the hour from these string in 24 hour format (in this case it would be, 13).
I have tried something like new Date('Sun May 10 2020 13:00:00 GMT-0800 (Pacific Standard Time)').getHours()
but that first converts the hour to system's current timezone and then returns the hour. Instead, I need to be able to retrieve the literal hour from variously formatted date strings such as the two above examples.
Edit: Obviously the above is not the correct approach, what I'm asking is, is there a universal way to parse the hour out of a date string, whether it be the above two examples or others, and without regex?