Probleme script date
reseau0010
Messages postés
278
Statut
Membre
-
reseau0010 Messages postés 278 Statut Membre -
reseau0010 Messages postés 278 Statut Membre -
Bonjour,
dans un site intranet j ai integré un script pour afficher la date, mais le probleme c 'est que la date se base sur leclient et pas sur le serveur:
exemple:
si la date au serveur est 07/07/2011 08:34
et la date chez le client est 02/11/2002 21:45
>>>>la date affiché sur le navigateur est 02/11/2002 21:45
comment je peux resoudre ce probléme
merci beaucoup
dans un site intranet j ai integré un script pour afficher la date, mais le probleme c 'est que la date se base sur leclient et pas sur le serveur:
exemple:
si la date au serveur est 07/07/2011 08:34
et la date chez le client est 02/11/2002 21:45
>>>>la date affiché sur le navigateur est 02/11/2002 21:45
comment je peux resoudre ce probléme
merci beaucoup
A voir également:
- Probleme script date
- Script vidéo youtube - Guide
- Mas script - Accueil - Windows
- Jm date avis - Forum Consommation & Internet
- Jm date désabonnement ✓ - Forum Consommation & Internet
- Abonnement jm date - Forum Consommation & Internet
6 réponses
Bonjour,
Si tu utilise du JavaScript, c'est normal: le javascript s'execute coté client unisquement.
Pour remedier a ton probleme, il te faut utiliser un moyen qui s'execute coté serveur.
Je te conseil pour cela d'utiliser du J2EE
Si tu utilise du JavaScript, c'est normal: le javascript s'execute coté client unisquement.
Pour remedier a ton probleme, il te faut utiliser un moyen qui s'execute coté serveur.
Je te conseil pour cela d'utiliser du J2EE
si tu peux m'aider le code de la date est :
<SCRIPT language=JavaScript>
var fixd;
function isGregLeapYear(year)
{
return year%4 == 0 && year%100 != 0 || year%400 == 0;
}
function gregToFixed(year, month, day)
{
var a = Math.floor((year - 1) / 4);
var b = Math.floor((year - 1) / 100);
var c = Math.floor((year - 1) / 400);
var d = Math.floor((367 * month - 362) / 12);
if (month <= 2)
e = 0;
else if (month > 2 && isGregLeapYear(year))
e = -1;
else
e = -2;
return 1 - 1 + 365 * (year - 1) + a - b + c + d + e + day;
}
function Hijri(year, month, day)
{
this.year = year;
this.month = month;
this.day = day;
this.toFixed = hijriToFixed;
this.toString = hijriToString;
}
function hijriToFixed()
{
return this.day + Math.ceil(29.5 * (this.month - 1)) + (this.year - 1) * 354 +
Math.floor((3 + 11 * this.year) / 30) + 227015 - 1;
}
function hijriToString()
{
var months = new Array("moharram","safar","rabii1","rabii2","joumada1","joumada2","rajab","chaabane","ramadane","chaoual","dou alkiida","dou alhijja");
return this.day-1 + " " + months[this.month - 1]+ " " + this.year;
}
function fixedToHijri(f)
{
var i=new Hijri(1100, 1, 1);
i.year = Math.floor((30 * (f - 227015) + 10646) / 10631);
var i2=new Hijri(i.year, 1, 1);
var m = Math.ceil((f - 29 - i2.toFixed()) / 29.5) + 1;
i.month = Math.min(m, 12);
i2.year = i.year;
i2.month = i.month;
i2.day = 1;
i.day = f - i2.toFixed() + 1;
return i;
}
var tod=new Date();
var weekday=new Array("dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi");
var monthname=new Array("janvier","fevrier","mars","avril","mai","juin","juillet","aout","septembre","octobre","novembre","decembre");
var y = tod.getFullYear();
var m = tod.getMonth();
var d = tod.getDate();
var dow = tod.getDay();
document.write(weekday[dow] + " " + d + " " + monthname[m] + " " + y);
m++;
fixd=gregToFixed(y, m, d);
var h=new Hijri(1421, 11, 28);
h = fixedToHijri(fixd);
document.write(" ap j.c - " + h.toString() + " hijir");
</SCRIPT>
<SCRIPT language=JavaScript>
var fixd;
function isGregLeapYear(year)
{
return year%4 == 0 && year%100 != 0 || year%400 == 0;
}
function gregToFixed(year, month, day)
{
var a = Math.floor((year - 1) / 4);
var b = Math.floor((year - 1) / 100);
var c = Math.floor((year - 1) / 400);
var d = Math.floor((367 * month - 362) / 12);
if (month <= 2)
e = 0;
else if (month > 2 && isGregLeapYear(year))
e = -1;
else
e = -2;
return 1 - 1 + 365 * (year - 1) + a - b + c + d + e + day;
}
function Hijri(year, month, day)
{
this.year = year;
this.month = month;
this.day = day;
this.toFixed = hijriToFixed;
this.toString = hijriToString;
}
function hijriToFixed()
{
return this.day + Math.ceil(29.5 * (this.month - 1)) + (this.year - 1) * 354 +
Math.floor((3 + 11 * this.year) / 30) + 227015 - 1;
}
function hijriToString()
{
var months = new Array("moharram","safar","rabii1","rabii2","joumada1","joumada2","rajab","chaabane","ramadane","chaoual","dou alkiida","dou alhijja");
return this.day-1 + " " + months[this.month - 1]+ " " + this.year;
}
function fixedToHijri(f)
{
var i=new Hijri(1100, 1, 1);
i.year = Math.floor((30 * (f - 227015) + 10646) / 10631);
var i2=new Hijri(i.year, 1, 1);
var m = Math.ceil((f - 29 - i2.toFixed()) / 29.5) + 1;
i.month = Math.min(m, 12);
i2.year = i.year;
i2.month = i.month;
i2.day = 1;
i.day = f - i2.toFixed() + 1;
return i;
}
var tod=new Date();
var weekday=new Array("dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi");
var monthname=new Array("janvier","fevrier","mars","avril","mai","juin","juillet","aout","septembre","octobre","novembre","decembre");
var y = tod.getFullYear();
var m = tod.getMonth();
var d = tod.getDate();
var dow = tod.getDay();
document.write(weekday[dow] + " " + d + " " + monthname[m] + " " + y);
m++;
fixd=gregToFixed(y, m, d);
var h=new Hijri(1421, 11, 28);
h = fixedToHijri(fixd);
document.write(" ap j.c - " + h.toString() + " hijir");
</SCRIPT>
Oui, ton script est des plus simple.
Mais comme je te l'ai dit, il s'execute coté client, donc sur l'ordinateur du l'utilisateur.
Pour qu'il s'execute coté serveur (sur ton PC) tu devra transformer ça en javascript.
Mais comme je te l'ai dit, il s'execute coté client, donc sur l'ordinateur du l'utilisateur.
Pour qu'il s'execute coté serveur (sur ton PC) tu devra transformer ça en javascript.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Malheureusement pour toi, je ne pourrait pas t'enseigner le J2EE car c'est trop complexe pour etre enseigné comme ça.
Je t'invite a suivre le cour donné sur le site du zero ici a propos de ce langage.
Je t'invite a suivre le cour donné sur le site du zero ici a propos de ce langage.