Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

string to datetime conversion javascript

Tags:

javascript

How do I convert string(09-Apr-2010) in to date time (09 April 2010 00:00:00) using java script? I need to compare the dates for validation.

like image 374
Dee Avatar asked Apr 09 '10 06:04

Dee


1 Answers

check out Date.parse

str = "09-Apr-2010"
date = new Date(Date.parse(str.replace(/-/g, " ")))
alert(date.toLocaleString())
like image 141
user187291 Avatar answered Nov 14 '22 23:11

user187291