Time-Service/page/js/clock.js

32 lines
1 KiB
JavaScript
Raw Permalink Normal View History

2019-01-10 21:06:58 +00:00
const offset = 49020000;
$(document).ready(function() {
// Create two variable with the names of the months and days in an array
2019-01-10 21:06:58 +00:00
var monthNames = [ "Januar" , "Febuar" , "März" , "April" , "Mai" , "Juni" , "Juli" , "August" , "September" , "Oktober" , "November" , "Dezember" ];
var dayNames= [ "Sonntag" , "Montag" , "Dienstag" , "Mittwoch" , "Donnerstag" , "Freitag" , "Samstag" ];
timeTick();
setInterval(timeTick, 1000);
2019-01-10 21:06:58 +00:00
function twoDigits (n) {
return (n < 10 ? '0': '') + n;
}
function timeTick() {
$('.point').css('animation-name', 'none');
2019-01-10 21:06:58 +00:00
const date = new Date();
date.setTime(date.getTime() - offset);
2019-01-10 21:06:58 +00:00
const seconds = date.getSeconds();
const minutes = date.getMinutes();
const hours = date.getHours();
$('#date').html(dayNames[date.getDay()] + " " + date.getDate() + ' ' + monthNames[2] + ' ' + date.getFullYear());
$("#sec").html(twoDigits(seconds));
$("#min").html(twoDigits(minutes));
$("#hours").html(twoDigits(hours));
$('.point').css('animation-name', 'flash');
}
})