JSFiddle - React, Tailwind, and code Playground
by jimkennelly
HTML
<div id="right">
<p>Current Date/Time is: <INPUT id="box1" name="box1" type="text" size="20"></p>
</div>
CSS
#right
{
float: right;
}
JavaScript
function update(){
time = new Date();
year = (time.getFullYear());
month = (time.getMonth() + 1);
date = time.getDate();
hours = time.getHours();
mins = time.getMinutes();
secs = time.getSeconds();
if(mins.length<2){mins = "0"+secs}
if(secs.length<2){secs = "0"+secs}
if(month.length<2){month = "0"+secs}
if(date.length<2){date = "0"+secs}
var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var d = new Date();
var dayName = days[d.getDay()];
// Config Starts
if(hours>12){hours=hours-12}else{hours}
format = year+"/"+month+"-"+date+" "+hours+":"+mins+":"+secs;
textbox = document.getElementById('box1');
textbox.value = dayName + ', ' + format ;
// Config Ends
}
setInterval("update()",1000);