728x90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSecondsTodayVerOne() { | |
const now = new Date(); | |
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); | |
const diff = now - today; | |
return Math.round(diff / 1000); | |
} | |
function getSecondsTodayVerTwo() { | |
const now = new Date(); | |
return now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds(); | |
} | |
console.log( getSecondsTodayVerOne() ); | |
console.log( getSecondsTodayVerTwo() ); |
'Algorithm > JavaScript(Node.js)' 카테고리의 다른 글
The Modern JS Tutorial: Date and Time: How many seconds till tomorrow (0) | 2021.12.06 |
---|---|
The Modern JS Tutorial: Date and Time: Last day of month (0) | 2021.12.02 |
The Modern JS Tutorial: Date and Time: Which day of month was many days ago (0) | 2021.11.30 |
The Modern JS Tutorial: Date and Time: European weekday (0) | 2021.11.29 |
The Modern JS Tutorial: Date and Time: show a weekday (0) | 2021.11.17 |