Merge pull request #603 from Chalarangelo/update-tomorrow
Update tomorrow
This commit is contained in:
@ -4,15 +4,17 @@ Results in a string representation of tomorrow's date.
|
|||||||
Use `new Date()` to get today's date, adding one day using `Date.getDate()` and `Date.setDate()`, and converting the Date object to a string.
|
Use `new Date()` to get today's date, adding one day using `Date.getDate()` and `Date.setDate()`, and converting the Date object to a string.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const tomorrow = () => {
|
const tomorrow = (long = false) => {
|
||||||
let t = new Date();
|
let t = new Date();
|
||||||
t.setDate(t.getDate() + 1);
|
t.setDate(t.getDate() + 1);
|
||||||
return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
|
const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
|
||||||
t.getDate()
|
t.getDate()
|
||||||
).padStart(2, '0')}`;
|
).padStart(2, '0')}`;
|
||||||
|
return !long ? ret : `${ret}T00:00:00`;
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
tomorrow(); // 2017-12-27 (if current date is 2017-12-26)
|
tomorrow(); // 2017-12-27 (if current date is 2017-12-26)
|
||||||
|
tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26)
|
||||||
```
|
```
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
const tomorrow = () => {
|
const tomorrow = () => {
|
||||||
let t = new Date();
|
let t = new Date();
|
||||||
t.setDate(t.getDate() + 1);
|
t.setDate(t.getDate() + 1);
|
||||||
return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
|
return `${String(t.getMonth() + 1).padStart(2, '0')}-${String(
|
||||||
t.getDate()
|
t.getDate()
|
||||||
).padStart(2, '0')}`;
|
).padStart(2, '0')}-${t.getFullYear()}`;
|
||||||
};
|
};
|
||||||
module.exports = tomorrow;
|
module.exports = tomorrow;
|
||||||
Reference in New Issue
Block a user