Update daysAgo.md

This commit is contained in:
Angelos Chalaris
2020-10-07 09:11:36 +03:00
committed by GitHub
parent 95c8618b36
commit bb6342ce24

View File

@ -9,7 +9,7 @@ Returns the date of `n` days ago from today as a string representation.
- 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
const daysAgo = (n) => { const daysAgo = n => {
let t = new Date(); let t = new Date();
t.setDate(t.getDate() - Math.abs(n)); t.setDate(t.getDate() - Math.abs(n));
return t.toISOString().split('T')[0]; return t.toISOString().split('T')[0];