Search code examples
javascriptstringdateformatlong-integer

How to convert long date value to string format in JavaScript


I want to know how to convert a long date like this 1542814586896 into a String format like this 2019/02/05


Solution

  • You can use Date class for setting time in integer format and getting any values like day, month, year

    let date = new Date(1542814586896);
    console.log(date.getDate(), date.getMonth(), date.getFullYear())