Eusthace Eusthace - 1 year ago 190
TypeScript Question

Check if date is greater than current date at 17:30

I have a date and a time parameters and I would like to check if that date/time is greater than the current date at 17:30.

I hope we could find a way using moment js. Is it possible?

I am trying this:

let d = moment(new Date()).set({hour:17,minute:30});
let t = moment(myDate).set({hour:paramHour,minute:paramMinute});

if ( t.isAfter(d) ) {

Thank you.

Answer Source

You probably don't need moment here. Something like this should work fine:

var now = new Date;
var cutoff = new Date;

if (now >= cutoff) {
    // Date is past 17:30
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download