Compare only time in Date - javascript -
this question has answer here:
- javascript parsing times without date 3 answers
how can compare time in js? let's have 2 dates :
date1 = tue apr 11 2017 12:30:00 date2 = tue apr 7 2017 02:30:00
and want make if statement
if(time of day in date1 after time of day in date2) { // }
how can achieve in clean , nice way?
if can use 3rd party libraries, have @ moment library. has isbefore , isafter methods should want.
if can't use 3rd party libraries, can use gethours()
, getminutes()
, , getseconds()
properties on date object.
Comments
Post a Comment