Plan stuff. Log stuff.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
325 B

4 years ago
  1. /**
  2. * Get a `YYYY-MM-DD` string.
  3. *
  4. * @param {Date} date
  5. */
  6. export default function dateStr(date) {
  7. function pad(n) {
  8. return n < 10 ? "0" + n : n.toString();
  9. }
  10. if (!(date instanceof Date)) {
  11. date = new Date(date);
  12. }
  13. return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
  14. }