-4

I have two dates:

D1 = 2017-05-01 00:00:00 and
D2 = Thu Jun 01 2017 16:12:08 GMT+0530 (India Standard Time) "d".

How can I compare these two dates in javascript?

if (D1>D2) { do something } else { do something}
8
  • 1
    change them to make them same format then compare Commented Jun 1, 2017 at 10:45
  • 2
    What have you tried so far yourself? Commented Jun 1, 2017 at 10:47
  • @CarstenLøvboAndersen. nothing. just find a way to make them in similar format. Commented Jun 1, 2017 at 10:48
  • 2
    Possible duplicate of Compare two date formats in javascript/jquery Commented Jun 1, 2017 at 10:49
  • 2
    Not sure why this was voted 'too broad', even from the original unedited question. The close reason just shows the first reason voted - it was also off-topic (not enough info) and a duplicate. Commented Jun 1, 2017 at 10:58

1 Answer 1

0

Why jquery? simply Do with new Date()

var D1 = '2017-05-01 00:00:00'
var D2 = 'Thu Jun 01 2017 16:12:08 GMT+0530';

console.log(new Date(D1).getTime(),new Date(D2).getTime())

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.