-3

I want to convert a particular date (say 31st October 2017) to the timestamp.

What should be my input and how to convert it into timestamp?

Sowmay Jain
  • 865
  • 1
  • 10
  • 21

1 Answers1

0

Just use getTime with new Date(date_to_parse)

var example="31 October, 2017";
alert(new Date(example).getTime());
IanS5
  • 94
  • 3
  • This is entirely dependent on browser behaviour - some may parse that format, some not - per the spec they aren't guaranteed to understand it. – James Thorpe Jul 31 '17 at 08:35
  • Works with "31 October, 2017", not with OP's "31st October 2017" --> NaN – Jeremy Thille Jul 31 '17 at 08:39
  • yeah, I think best way around that is to just get rid of the "st" by doing `.replace('st','')` or something along those lines. – IanS5 Jul 31 '17 at 08:47