Final cleanup of tomorrow snippet
This commit is contained in:
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
Results in a string representation of tomorrow's date.
|
Results in a string representation of tomorrow's date.
|
||||||
|
|
||||||
First we use `new Date()` to get today's date, then add one day using `Date.getDate()` and mutate the initial `Date` via `Date.setDate()`. Then we use construct the date string in `yyyy-mm-dd` format.
|
Use `new Date()` to get the current date, increment by one using `Date.getDate()` and set the value to the result using `Date.setDate()`.
|
||||||
|
Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const tomorrow = () => {
|
const tomorrow = () => {
|
||||||
@ -14,6 +15,4 @@ const tomorrow = () => {
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
tomorrow(); // 2018-10-18 (if current date is 2018-10-18)
|
tomorrow(); // 2018-10-18 (if current date is 2018-10-18)
|
||||||
// if you need the time to indicate the start of the day as well:
|
|
||||||
`${tomorrow()}T00:00:00}: // 2018-10-18T00:00:00
|
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user