I took this code from PHP with javascript code, live clock , and successfully put it on my website. The code is here:
<?php
function d1() {
$time1 = time();
$date1 = date("h:i:sa",$time1);
echo $date1;
}
?>
<script>
var now = new Date(<?php echo time() * 1000 ?>);
function startInterval(){
setInterval('updateTime();', 1000);
}
startInterval();//start it right away
function updateTime(){
var nowMS = now.getTime();
nowMS += 1000;
now.setTime(nowMS);
var clock = document.getElementById('qwe');
if(clock){
clock.innerHTML = now.toTimeString();//adjust to suit
}
}
</script>
<div id="qwe"></div>
However, the time format shows up as this:
21:41:44 GMT-0400 (Eastern Standard Time)
I want it to show up as
9:41:44 PM
I assume that this line
clock.innerHTML = now.toTimeString();//adjust to suit
is the one I need to change, but can't find any formats that show it very simply. Do I need to write something up myself to show it in this custom format?