-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}
freedomn-m
  • 24,983
  • 7
  • 32
  • 55
Jay Momaya
  • 1,548
  • 16
  • 27

1 Answers1

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())
prasanth
  • 21,342
  • 4
  • 27
  • 50