JavaScript: Get current time

JavaScript: Get current time

  • 2020-1-16
  1. Get milliseonds elapsed since January 1, 1970 00:00:00 UTC.

    1
    Date.now() // example: 1579110392189

  2. Get a Date

    1
    2
    3
    new Date()
    // examlpe1 (Chrome 81): Thu Jan 16 2020 01:55:06 GMT+0800 (China Standard Time)
    // example2 (Node 13.6.0): 2020-01-15T17:51:41.575Z