Skip to content

Instantly share code, notes, and snippets.

@rhcarlosweb
Created March 16, 2020 22:28
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 rhcarlosweb/f3c1879b9233d158618d1bf0f1dbff55 to your computer and use it in GitHub Desktop.
Save rhcarlosweb/f3c1879b9233d158618d1bf0f1dbff55 to your computer and use it in GitHub Desktop.
Date
/**
* Dates
*/
const days = 3;
const date = new Date();
const last = new Date(date.getTime() + (days * 24 * 60 * 60 * 1000));
const day = last.getDate();
const month = last.getMonth() + 1;
const year = last.getFullYear();
const dayEl = document.querySelector('.day');
const monthEl = document.querySelector('.month');
const yearEl = document.querySelector('.year');
dayEl.textContent = day;
monthEl.textContent = last.toLocaleString('default', { month: 'long' });
yearEl.textContent = year;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment