Skip to content

Instantly share code, notes, and snippets.

@mezerotm
Last active March 25, 2022 23:13
Show Gist options
  • Save mezerotm/da8e9a561bfb834667894839a3b19146 to your computer and use it in GitHub Desktop.
Save mezerotm/da8e9a561bfb834667894839a3b19146 to your computer and use it in GitHub Desktop.
Some common operations I perform with Unix time
const SECONDS_IN_A_DAY = 86400
let sts = 1629072000
let ets = 0
const unixMidnight = time => {
return time - (time % SECONDS_IN_A_DAY)
}
const addDay = time => {
return time + SECONDS_IN_A_DAY
}
const getNextDays = (time, nextDays) => {
const days = []
for (let i = 0; i < nextDays; i++) {
days.push(time)
time = addDay(time)
}
return days
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment