-1

I want to convert "04/09/2013" to date so I can compare start date and end date like, if (stardate < enddate) { //do this } else {}. I want to convert it to MM/DD/YYYY format.

Ram
  • 661
  • 2
  • 12
  • 37
  • Please provide what you've tried and what errors you're running into - if any. – anAgent Apr 08 '13 at 21:10
  • 1
    See here: http://stackoverflow.com/questions/1576753/parse-datetime-string-in-javascript – Dimitris Fousteris Apr 08 '13 at 21:10
  • 1
    [What have you tried?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) There is a thousand of almost exactly similar questions here. And you didn't even specify whether you want `dd/mm/yyyy` or `mm/dd/yyyy` format. – Fabrício Matté Apr 08 '13 at 21:11
  • `var d = new Date("04/09/2013");` Watch out for UTC vs. Local time though. This might end up being April 9th or September 4th. – Cᴏʀʏ Apr 08 '13 at 21:11
  • You may want to read this: http://blog.dygraphs.com/2012/03/javascript-and-dates-what-mess.html – Cᴏʀʏ Apr 08 '13 at 21:14

1 Answers1

0

It's very difficult to work with Dates in JavaScript. I highly recommend you use moment.js library

http://momentjs.com/

simple-thomas
  • 671
  • 7
  • 20