Update dayName.md
This commit is contained in:
@ -3,15 +3,13 @@ title: dayName
|
|||||||
tags: date,beginner
|
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 `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
|
```js
|
||||||
const dayName = ( date, locale ) =>
|
const dayName = (date, locale) => date.toLocaleDateString(locale, { weekday: 'long' });
|
||||||
date.toLocaleDateString(locale, { weekday: 'long' })
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
Reference in New Issue
Block a user