How do I get the time of day in javascript/Node.js?

后端 未结 9 832
青春惊慌失措
青春惊慌失措 2020-12-23 13:23

I want to get 1 to 24, 1 being 1am Pacific Time.

How can I get that number in Node.JS?

I want to know what time it is in Pacific time right

9条回答
  •  旧时难觅i
    2020-12-23 13:48

    If you only want the time string you can use this expression (with a simple RegEx):

    new Date().toISOString().match(/(\d{2}:){2}\d{2}/)[0]
    // "23:00:59"
    

提交回复
热议问题