Alternative solution
This commit is contained in:
parent
13be80afb9
commit
02942eb420
1 changed files with 16 additions and 0 deletions
|
@ -13,3 +13,19 @@ function getSecondsToTomorrow() {
|
|||
return Math.round(diff / 1000); // convert to seconds
|
||||
}
|
||||
```
|
||||
|
||||
Alternative solution:
|
||||
|
||||
```js run
|
||||
function getSecondsToTomorrow() {
|
||||
let now = new Date();
|
||||
let hour = now.getHours();
|
||||
let minutes = now.getMinutes();
|
||||
let seconds = now.getSeconds();
|
||||
let totalSecondsToday = (hour * 60 + minutes) * 60 + seconds;
|
||||
let totalSecondsInADay = 86400;
|
||||
|
||||
return totalSecondsInADay - totalSecondsToday;
|
||||
}
|
||||
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue