-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?

2
  • What have you tried so far? Did you even google that question first? Commented Jul 31, 2017 at 8:28
  • @TheRickest new Date("31st October 2017") --> Invalid Date, the thread you point at is about dates formats like 31-10-2017 Commented Jul 31, 2017 at 8:30

1 Answer 1

0

Just use getTime with new Date(date_to_parse)

var example="31 October, 2017";
alert(new Date(example).getTime());

Sign up to request clarification or add additional context in comments.

3 Comments

This is entirely dependent on browser behaviour - some may parse that format, some not - per the spec they aren't guaranteed to understand it.
Works with "31 October, 2017", not with OP's "31st October 2017" --> NaN
yeah, I think best way around that is to just get rid of the "st" by doing .replace('st','') or something along those lines.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.