Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 598 Bytes

dayName.md

File metadata and controls

22 lines (18 loc) · 598 Bytes
title tags expertise firstSeen lastUpdated
Day name
date
beginner
2020-10-04 00:31:08 +0300
2020-11-01 20:50:57 +0200

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 argument 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'