Skip to content

Instantly share code, notes, and snippets.

@BrianMehrman
Last active June 17, 2017 22:36
Show Gist options
  • Save BrianMehrman/c15300c2aaffdafe4fe4c2b1997d3c47 to your computer and use it in GitHub Desktop.
Save BrianMehrman/c15300c2aaffdafe4fe4c2b1997d3c47 to your computer and use it in GitHub Desktop.
Code to alter date quickly
const daysAgo = ((days, date) => { let d = date || new Date(); d.setDate(d.getDate() - (days || 1)); return d; });
const hoursAgo = ((hours, date) => { let d = date || new Date(); d.setHours(d.getHours() - (hours || 1)); return d; });
const mintuesAgo = ((mins, date) => { let d = date || new Date(); d.setMinutes(d.getMinutes() - (mins || 1)); return d; });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment