javascript - How to compare only date in moment.js -



javascript - How to compare only date in moment.js -

i new moment.js. have date object , has time associated it. want compare if date greater or equal today's date, excluding time when comparing.

var datetocompare = 2015-04-06t18:30:00.000z

i want check if datetocompare equal or greater today's date. have checked issame of moment.js, seems take string , date part. not want convert date string or manipulate further. because worried javascript may unexpected when converting date string(like adding offset or dst,etc), or may wrong.

sample issame() docs

moment('2010-10-20').issame('2010-10-20');

also looking issame() , isafter() combined 1 statement.

i need compare using moment.js only.please not suggest plain javascript date comparison.

the docs pretty clear pass in sec parameter specify granularity.

if want limit granularity unit other milliseconds, pass units sec parameter.

moment('2010-10-20').isafter('2010-01-01', 'year'); // false moment('2010-10-20').isafter('2009-12-31', 'year'); // true

for case pass 'day' sec parameter.

javascript momentjs

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -