Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 509 Bytes

dayName.md

File metadata and controls

18 lines (14 loc) · 509 Bytes
title tags
dayName
date,beginner

Gets the name of the weekday from a Date object.

  • Use Date.prototype.toLocaleDateString() with the { weekday: 'long' } option to retrieve the weekday.
  • Use the optional second parameter to get a language-specific name or omit it to use the default locale.
const dayName = (date, locale) => date.toLocaleDateString(locale, { weekday: 'long' });
dayName(new Date()); // 'Saturday'
dayName(new Date('09/23/2020'), 'de-DE'); // 'Samstag'