Update dayName.md

This commit is contained in:
Angelos Chalaris
2020-10-04 00:59:36 +03:00
committed by GitHub
parent 5407e6f36a
commit 0e3d752c22

View File

@ -3,15 +3,13 @@ title: dayName
tags: date,beginner
---
Gets the name of the weekday from a `Date` object, optionally for a given locale.
Gets the name of the weekday from a `Date` object.
- Use `new Date()` or `new Date('mm/dd/yyyy')` to find the weekday.
- Use `Date.prototype.toLocaleDateString()` with the `{ weekday: 'long' }` option to retrieve the weekday.
- Use the optional second parameter for language specific name. If not used, returns the default locale.
- Use the optional second parameter to get a language-specific name or omit it to use the default locale.
```js
const dayName = ( date, locale ) =>
date.toLocaleDateString(locale, { weekday: 'long' })
const dayName = (date, locale) => date.toLocaleDateString(locale, { weekday: 'long' });
```
```js