1

Currently I am getting date as string 1524801600000. I want to convert it as new Date(2018, 4, 27).

How can I do that using jQuery or JavaScript?

maytham-ɯɐɥʇʎɐɯ
  • 21,551
  • 10
  • 85
  • 103
user9241515
  • 57
  • 1
  • 8
  • Check https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date in case you need to format it later – JPRLCol Jan 26 '18 at 21:34

1 Answers1

3

Just pass it to Date Constructor.

(+) Unary operator. Attempts to convert the operand to a number, if it is not already. more details here

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators

var temp="1524801600000";
var p=new Date(+temp)
console.log(p)
sumeet kumar
  • 2,526
  • 1
  • 12
  • 22