How to compare the date part alone from a date time value

后端 未结 4 2056
栀梦
栀梦 2020-12-15 16:21

I have two variables namely

date1 = Mon Nov 25 2013 00:00:00 GMT+0530 (IST)
date2 = Mon Nov 25 2013 14:13:55 GMT+0530 (IST)

When I compare

4条回答
  •  天命终不由人
    2020-12-15 16:25

    The best way would be to modify the accepted answer's if statement as follows

    if(d.setHours(0,0,0,0) >= today.setHours(0,0,0,0))
    

    In this way, you can easily check for equality as well because the return type for setHours() is integer.

提交回复
热议问题