Skip to content

Instantly share code, notes, and snippets.

@guaiamum
Created October 27, 2017 13:33
Show Gist options
  • Save guaiamum/ac95ddc7547aa5cb42ea3bc177f4adfe to your computer and use it in GitHub Desktop.
Save guaiamum/ac95ddc7547aa5cb42ea3bc177f4adfe to your computer and use it in GitHub Desktop.
Javascript Date Snippets
/* FIRST AND LAST DAY OF WEEK */
var curr = new Date; // get current date
var first = curr.getDate() - curr.getDay(); // First day is the day of the month - the day of the week
var last = first + 6; // last day is the first day + 6
var firstday = new Date(curr.setDate(first)).toUTCString();
var lastday = new Date(curr.setDate(last)).toUTCString();
/* TOMORROW */
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment