Skip to content

Instantly share code, notes, and snippets.

@kivircik-parantez
Created December 27, 2022 10:13
Show Gist options
  • Save kivircik-parantez/bf421c18c978683ffed44aa6b2042a62 to your computer and use it in GitHub Desktop.
Save kivircik-parantez/bf421c18c978683ffed44aa6b2042a62 to your computer and use it in GitHub Desktop.
Date Calculations
moment('2010-10-20').isBefore('2010-10-21');
moment('2010-10-20').isBefore('2010-12-31', 'year'); // false
moment('2010-10-20').isSame('2010-10-20'); // true
moment('2010-10-20').isAfter('2010-10-19'); // true
moment('2010-10-20').isSameOrBefore('2010-10-21'); // true
moment('2010-10-20').isSameOrAfter('2010-10-21'); // false
moment('2010-10-20').isBetween('2010-10-19', '2010-10-25'); // true
moment('2010-10-20').isBetween('2010-10-19', undefined); // true, since moment(undefined) evaluates as moment()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment