Skip to content

Instantly share code, notes, and snippets.

@FreePhoenix888
Created October 2, 2020 09:56
Show Gist options
  • Save FreePhoenix888/221fe9ec0734383e52153399d14be688 to your computer and use it in GitHub Desktop.
Save FreePhoenix888/221fe9ec0734383e52153399d14be688 to your computer and use it in GitHub Desktop.
function getSecondsToday() {
let now = new Date();
let today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
let diff = now - today; // разница в миллисекундах
return Math.round(diff / 1000); // получаем секунды
}
alert( getSecondsToday() );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment