How to convert a number to a date in JavaScript

35,498

You can use this:

var date = new Date(1546108200 * 1000);
console.log(date.toUTCString())

Share:
35,498

Related videos on Youtube

K Vinodh Kumar
Author by

K Vinodh Kumar

Updated on March 31, 2022

Comments

  • K Vinodh Kumar
    K Vinodh Kumar over 1 year

    I have a number, "1546108200", in epoch format.

    I want to convert into a date format, like "Sunday, December 30, 2018 12:00:00 AM".

    How can I do that?

    • ic3b3rg
      ic3b3rg almost 5 years
      new Date(1546108200 * 1000)
    • Code Maniac
      Code Maniac almost 5 years
      Where you're facing problem ?
    • Peter Mortensen
      Peter Mortensen over 1 year
      "epoch format" = Unix time?
  • Nick
    Nick over 1 year
    why do you need to multiply with 1000?