Skip to content

Instantly share code, notes, and snippets.

@tomkis
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomkis/898794c227670d199e78 to your computer and use it in GitHub Desktop.
Save tomkis/898794c227670d199e78 to your computer and use it in GitHub Desktop.
// incorrect, does not work for the exact midnight
var today = moment(),
yesterday = moment().subtract(1, 'days');
// correct but ugly
var today = moment(),
yesterday = today.clone().subtract(1, 'days');
// pretty but unable to write with momentjs because instance is not immutable
var today = moment(),
yesterday = today.subtract(1, 'days');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment