L'heure sur mon site web

Résolu/Fermé
julinou76 Messages postés 155 Date d'inscription mardi 4 novembre 2008 Statut Membre Dernière intervention 27 août 2011 - 18 mars 2009 à 18:25
zoby44 Messages postés 818 Date d'inscription vendredi 3 novembre 2006 Statut Membre Dernière intervention 7 avril 2010 - 18 mars 2009 à 18:46
Bonjour,
je voudrais savoir quelle est le code javascript ou un otre code pour afficher l'heure comme sur ce site:
http://www.galinottes.net/
merci d'avance
A voir également:

1 réponse

zoby44 Messages postés 818 Date d'inscription vendredi 3 novembre 2006 Statut Membre Dernière intervention 7 avril 2010 199
18 mars 2009 à 18:46
Salut, le code sur ce site est :
<html>
<head>
	<script type="text/javascript">
		var dayarray=new Array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi")
		var montharray=new Array("Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre")
		function getthedate(){
			var mydate=new Date()
			var year=mydate.getYear()
			if (year < 1000) 
				year+=1900
			var day=mydate.getDay()
			var month=mydate.getMonth()
			var daym=mydate.getDate()
			if (daym<10)
				daym="0"+daym
			var hours=mydate.getHours()
			var minutes=mydate.getMinutes()
			var seconds=mydate.getSeconds()
			var dn="AM"
			if (hours>=12)
				dn="PM"
			if (hours>12){
				hours=hours-12
			}
			if (hours==0)
				hours=12
			if (minutes<=9)
				minutes="0"+minutes
			if (seconds<=9)
				seconds="0"+seconds
	
			//change font size here
			var cdate="<font size='1' color='50ACB9' face='Arial'>"+dayarray[day]+" "+daym+" "+montharray[month]+"<br>"+hours+":"+minutes+":"+seconds+" "+dn+"</font>"
			
			if (document.all)
				document.all.clock.innerHTML=cdate
			else if (document.getElementById)
				document.getElementById("clock").innerHTML=cdate
			else
				document.write(cdate)
		}
		if (!document.all&&!document.getElementById)
			getthedate()
		window.onload = function(){
			if (document.all||document.getElementById)
				setInterval("getthedate()",1000)
		}
		</script>
</head>
<body>
<div id="clock"></div>
</body>
</html>


Testé sous Firefox 3, ie6, ie7, chrome et safari.
1