-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
  • 27,664
  • 8
  • 35
  • 57
Jay Momaya
  • 1,831
  • 19
  • 32

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
  • 22,145
  • 4
  • 29
  • 53