Compare only time in Date - javascript -


this question has answer here:

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

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -