Update formatting
This commit is contained in:
@ -2,12 +2,13 @@
|
|||||||
title: daysAgo
|
title: daysAgo
|
||||||
tags: date,beginner
|
tags: date,beginner
|
||||||
firstSeen: 2020-10-06T05:35:23+03:00
|
firstSeen: 2020-10-06T05:35:23+03:00
|
||||||
lastUpdated: 2020-10-20T11:21:07+03:00
|
lastUpdated: 2022-01-30T11:48:07+03:00
|
||||||
---
|
---
|
||||||
|
|
||||||
Calculates the date of `n` days ago from today as a string representation.
|
Calculates the date of `n` days ago from today as a string representation.
|
||||||
|
|
||||||
- Use `new Date()` to get the current date, `Math.abs()` and `Date.prototype.getDate()` to update the date accordingly and set to the result using `Date.prototype.setDate()`.
|
- Use the `Date` constructor to get the current date.
|
||||||
|
- Use `Math.abs()` and `Date.prototype.getDate()` to update the date accordingly and set to the result using `Date.prototype.setDate()`.
|
||||||
- Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format.
|
- Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@ -2,12 +2,13 @@
|
|||||||
title: daysFromNow
|
title: daysFromNow
|
||||||
tags: date,beginner
|
tags: date,beginner
|
||||||
firstSeen: 2020-10-09T02:49:17+03:00
|
firstSeen: 2020-10-09T02:49:17+03:00
|
||||||
lastUpdated: 2020-10-20T11:21:07+03:00
|
lastUpdated: 2022-01-30T11:48:07+03:00
|
||||||
---
|
---
|
||||||
|
|
||||||
Calculates the date of `n` days from today as a string representation.
|
Calculates the date of `n` days from today as a string representation.
|
||||||
|
|
||||||
- Use `new Date()` to get the current date, `Math.abs()` and `Date.prototype.getDate()` to update the date accordingly and set to the result using `Date.prototype.setDate()`.
|
- Use the `Date` constructor to get the current date.
|
||||||
|
- Use `Math.abs()` and `Date.prototype.getDate()` to update the date accordingly and set to the result using `Date.prototype.setDate()`.
|
||||||
- Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format.
|
- Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
Reference in New Issue
Block a user