Javascript new Date not working in IE (Invalid Date)

I have a script that works fine in chrome but cannot convert the date in IE and gives an invalid date error.
I know it is something to do with the way the date is formatted that IE doesn't like.

I am passsing this date in Chrome from a label on a page (2015-05-27 03:00:00 PM)

               var ASPDate = document.getElementById('<%=LabelCutoffTime.ClientID%>').innerText;

               var ASPfutureDate = new Date(ASPDate);

Error in IE
RBG ITAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
yes, the date parsing is different in various browsers and even their versions.
You have three options:
1. Use a nice utility JavaScript library called moment.js - where you can create dates providing format options
2. Take the date string as it is and manually parse / split / manipulate it and create the date using the different parts
3. Provide the date string in a format each browser behaves the same (which is afaik only a theoretical solution)
If you want to go with option 2, I would be happy to provide sample code.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RobOwner (Aidellio)Commented:
(no points please) I just want to +1 on the moment.js library.  Makes parsing a breeze.
Dave BaldwinFixer of ProblemsCommented:
Where are you getting 'PM' in the second example?  I can't find any support for AM/PM in javascript date functions.  Except in "toLocaleString()".  Firefox and Chrome produce the same results but IE8 is different.
5/28/2015, 7:01:35 PM // Chrome and Firefox
Thursday, May 28, 2015 7:02:06 PM // IE8

Open in new window
RBG ITAuthor Commented:
Absolutely tremendous 5 mins all done, thanks guys!
Michel PlungjanIT ExpertCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.