Temps de conception et Date

  • sase_95
  • Banned
  • Banned
  • Avatar de l’utilisateur
  • Inscription: Aoû 27, 2010
  • Messages: 17
  • Loc: Neg, MK
  • Status: Offline

Message Août 30th, 2010, 10:29 am

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
Code: [ Select ]
<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>
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function startTime()
  5. {
  6. var today=new Date();
  7. var h=today.getHours();
  8. var m=today.getMinutes();
  9. var s=today.getSeconds();
  10. // add a zero in front of numbers<10
  11. m=checkTime(m);
  12. s=checkTime(s);
  13. document.getElementById('txt').innerHTML=h+":"+m+":"+s;
  14. t=setTimeout('startTime()',500);
  15. }
  16. function checkTime(i)
  17. {
  18. if (i<10)
  19.  {
  20.  i="0" + i;
  21.  }
  22. return i;
  23. }
  24. </script>
  25. <title>Clock</title></head>
  26. <body onLoad="startTime()">
  27. <div id="txt"></div>
  28. </body>
  29. </html>





D ate
Code: [ Select ]
<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>
  1. <script language="JavaScript">
  2. <!--
  3. function getCorrectedYear(year) {
  4. year = year - 0;
  5. if (year < 70) return (2000 + year);
  6. if (year < 1900) return (1900 + year);
  7. return year;
  8. }
  9. var lmod = new Date();
  10. var monthname;
  11. var lmonth = lmod.getMonth();
  12. if (lmonth == 0) monthname = "January";
  13. if (lmonth == 1) monthname = "February";
  14. if (lmonth == 2) monthname = "March";
  15. if (lmonth == 3) monthname = "April";
  16. if (lmonth == 4) monthname = "May";
  17. if (lmonth == 5) monthname = "June";
  18. if (lmonth == 6) monthname = "July";
  19. if (lmonth == 7) monthname = "August";
  20. if (lmonth == <!-- s8) --><img src=\"{SMILIES_PATH}/icon_cool.gif\" alt=\"8)\" title=\"Cool\"><!-- s8) --> monthname = "September";
  21. if (lmonth == 9) monthname = "October";
  22. if (lmonth == 10) monthname = "November";
  23. if (lmonth == 11) monthname = "December";
  24. var yearstr = getCorrectedYear(lmod.getYear());
  25. var outstr = monthname + " " + lmod.getDate() + ", " + yearstr;
  26. document.write(outstr);
  27. // -->
  28. </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!
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Août 30th, 2010, 10:29 am

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • Avatar de l’utilisateur
  • Inscription: Mai 22, 2004
  • Messages: 3415
  • Loc: Richland, WA
  • Status: Offline

Message Août 30th, 2010, 2:11 pm

Javascript s'exécute hors de la machine cliente afin Im ne savez pas comment vous faire un serveur de temps ;)
#define NULL (::rand() % 2)
  • sase_95
  • Banned
  • Banned
  • Avatar de l’utilisateur
  • Inscription: Aoû 27, 2010
  • Messages: 17
  • Loc: Neg, MK
  • Status: Offline

Message Août 30th, 2010, 3:46 pm

SpooF a écrit:
Javascript s'exécute hors de la machine cliente afin Im ne savez pas comment vous faire un serveur de temps ;)

Wow Désolé mon erreur que je voulais dire script heure de l'horloge - qui montre le temps!
:D gif "alt =": D "title =" très heureux "> Je suis tellement nobb:] :D:):P

Afficher de l'information

  • Total des messages de ce sujet: 3 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 172 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC