Files
amble_api/public/js/timestamp.js
2025-07-15 15:54:43 +05:30

40 lines
1.4 KiB
JavaScript

//create document ready function
$(document).ready(function(){
function displayTimestamp(){
var currentDate = new Date();
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var year = currentDate.getFullYear();
var date = currentDate.getDate();
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
var month = months[currentDate.getMonth()];
if (date<10){
date = "0" + date;
}
var day = days[currentDate.getDay()];
var hours = currentDate.getHours();
var minutes = currentDate.getMinutes();
var seconds = currentDate.getSeconds();
var meridiem = " AM";
if(hours>11){
hours = hours - 12;
meridiem = " PM";
}
if(hours === 0){
hours = 12;
}
if (hours<10){
hours = "0" + hours;
}
if (minutes<10){
minutes = "0" + minutes;
}
if (seconds<10){
seconds = "0" + seconds;
}
$("#timestamp").text(hours +":"+ minutes +":"+ seconds + meridiem +" | "+ day +" | "+ month +" "+ date +", "+ year);
}
setInterval(displayTimestamp, 1000);
});