Salut les gars Im en train de concevoir un serveur de temps et une date:
Si vous avez un site et que vous souhaitez afficher l'heure et la date voici une idée!
T emps
<html>
<head>
<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
<title>Clock</title></head>
<body onLoad="startTime()">
<div id="txt"></div>
</body>
</html>
- <html>
- <head>
- <script type="text/javascript">
- function startTime()
- {
- var today=new Date();
- var h=today.getHours();
- var m=today.getMinutes();
- var s=today.getSeconds();
- // add a zero in front of numbers<10
- m=checkTime(m);
- s=checkTime(s);
- document.getElementById('txt').innerHTML=h+":"+m+":"+s;
- t=setTimeout('startTime()',500);
- }
- function checkTime(i)
- {
- if (i<10)
- {
- i="0" + i;
- }
- return i;
- }
- </script>
- <title>Clock</title></head>
- <body onLoad="startTime()">
- <div id="txt"></div>
- </body>
- </html>
D ate
<script language="JavaScript">
<!--
function getCorrectedYear(year) {
year = year - 0;
if (year < 70) return (2000 + year);
if (year < 1900) return (1900 + year);
return year;
}
var lmod = new Date();
var monthname;
var lmonth = lmod.getMonth();
if (lmonth == 0) monthname = "January";
if (lmonth == 1) monthname = "February";
if (lmonth == 2) monthname = "March";
if (lmonth == 3) monthname = "April";
if (lmonth == 4) monthname = "May";
if (lmonth == 5) monthname = "June";
if (lmonth == 6) monthname = "July";
if (lmonth == 7) monthname = "August";
if (lmonth == <!-- s8) --><img src=\"{SMILIES_PATH}/icon_cool.gif\" alt=\"8)\" title=\"Cool\"><!-- s8) --> monthname = "September";
if (lmonth == 9) monthname = "October";
if (lmonth == 10) monthname = "November";
if (lmonth == 11) monthname = "December";
var yearstr = getCorrectedYear(lmod.getYear());
var outstr = monthname + " " + lmod.getDate() + ", " + yearstr;
document.write(outstr);
// -->
</script>
- <script language="JavaScript">
- <!--
- function getCorrectedYear(year) {
- year = year - 0;
- if (year < 70) return (2000 + year);
- if (year < 1900) return (1900 + year);
- return year;
- }
- var lmod = new Date();
- var monthname;
- var lmonth = lmod.getMonth();
- if (lmonth == 0) monthname = "January";
- if (lmonth == 1) monthname = "February";
- if (lmonth == 2) monthname = "March";
- if (lmonth == 3) monthname = "April";
- if (lmonth == 4) monthname = "May";
- if (lmonth == 5) monthname = "June";
- if (lmonth == 6) monthname = "July";
- if (lmonth == 7) monthname = "August";
- if (lmonth == <!-- s8) --><img src=\"{SMILIES_PATH}/icon_cool.gif\" alt=\"8)\" title=\"Cool\"><!-- s8) --> monthname = "September";
- if (lmonth == 9) monthname = "October";
- if (lmonth == 10) monthname = "November";
- if (lmonth == 11) monthname = "December";
- var yearstr = getCorrectedYear(lmod.getYear());
- var outstr = monthname + " " + lmod.getDate() + ", " + yearstr;
- document.write(outstr);
- // -->
- </script>
Vous pouvez également modifier les noms des mois dans votre propre langue!
Ainsi, thats it!
Désolé si je n'étais pas du tout d'aide Im juste un débutant dans ce!
THX pour la lecture!