El index.html
Código HTML:
<head>
<title>clock</title>
</head>
<body>
<!-- ### clock ### //-->
<div id="Clock">AQUI IRA LA HORA</div>
<script type="text/javascript">
<!--
var DayNam = new Array(
"Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
var MnthNam = new Array(
"Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
//-->
</script>
<script type="text/javascript" src="clock.js"></script>
<!-- ### end clock ### //-->
</body>
</html>
y clock.js
Código PHP:
<!--
function tick() {
var hours, minutes, seconds, ap;
var intHours, intMinutes, intSeconds; var today;
today = new Date();
intDay = today.getDay();
intDate = today.getDate();
intMonth = today.getMonth();
intYear = today.getYear();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
timeString = DayNam[intDay]+" "+intDate;
if (intDate == 1 || intDate == 21 || intDate == 31) {
timeString= timeString + " ";
} else if (intDate == 2 || intDate == 22) {
timeString= timeString + " ";
} else if (intDate == 3 || intDate == 23) {
timeString= timeString + " ";
} else {
timeString = timeString + " ";
}
if (intYear < 2000){
intYear += 1900;
}
timeString = timeString+" de "+MnthNam[intMonth]+" de "+intYear;
if (intHours == 0) {
hours = "12:";
ap = "am.";
} else if (intHours < 12) {
hours = intHours+":";
ap = "am.";
} else if (intHours == 12) {
hours = "12:";
ap = "pm.";
} else {
intHours = intHours - 12
hours = intHours + ":";
ap = "pm.";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes;
} else {
minutes = intMinutes;
}
if (intSeconds < 10) {
seconds = ":0"+intSeconds;
} else {
seconds = ":"+intSeconds;
}
timeString = (document.all)? timeString+", "+hours+minutes+seconds+" "+ap:timeString+" "+hours+minutes+" "+ap;
var clock = (document.all) ? document.all("Clock") : document.getElementById("Clock");
clock.innerHTML = timeString;
(document.all)?window.setTimeout("tick();", 1000):window.setTimeout("tick();", 6000);
}
tick();
//-->