Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (7k points)

I want to convert the date to timestamp. Can anyone tell me how to do this?

1 Answer

0 votes
by (7k points)

You can do it like this:

var myDate = "26-02-2012";

myDate = myDate.split("-");

var newDate = new Date( myDate[2], myDate[1] - 1, myDate[0]);

console.log(newDate.getTime());

Want to learn Full Stack Development? Check out the Full Stack Development course from Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...