Link to home
Start Free TrialLog in
Avatar of smares323
smares323

asked on

Javascript Date

How can I convert this date 3/19/2014 12:00:00 to a javascript  new Date(2014,2,19,10,7,0) format, I know that the month starts at 0
Avatar of leakim971
leakim971
Flag of Guadeloupe image

var str = "3/19/2014 12:00:00";
var arr = str.split(/\D/);
var d = new Date( arr[2], arr[0]*1-1, arr[1], arr[3], arr[4], arr[5] );

Open in new window

Avatar of smares323
smares323

ASKER

Not working it outputs Wed Mar 19 2014 12:00:00 GMT-0700 (Pacific Standard Time
I want to convert it to this forma new Date(2014,2,19,10,7,0)
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm passing this variable '3/19/2014 12:00:00' and need to put into this format new Date(2014,2,19,10,7,0) for javascript.
you already have the code for that but you certainly made an alert(d) to check and think you did not get it.
I give you both, the string and the required date
if you do an alert you will see your DATE in a STRING representation : Wed Mar 19 2014 12:00:00 GMT-0700
great work