-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.

5
  • Please provide what you've tried and what errors you're running into - if any. Commented Apr 8, 2013 at 21:10
  • 1
    See here: stackoverflow.com/questions/1576753/… Commented Apr 8, 2013 at 21:10
  • 1
    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. Commented Apr 8, 2013 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. Commented Apr 8, 2013 at 21:11
  • You may want to read this: blog.dygraphs.com/2012/03/javascript-and-dates-what-mess.html Commented Apr 8, 2013 at 21:14

1 Answer 1

0

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

http://momentjs.com/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.