fonctions getdate et gettime

fonctions getdate et gettime - HTML/CSS - Programmation

Marsh Posté le 15-11-2007 à 14:29:14    

bonjour,
 
j'ai une fonction qui compare deux dates, ca marche tres bien sauf quand on change de mois
 
la date d'aujourdh'hui (la variable aujourd'hui), donc
le 15/11/2007 va me donner 1197724329593
 
le 29/11/2007 va me donner 1198933539687
le 30/11/2007 va me donner 1199019939687
le 01/12/2007 va me donner 1167656739687
 
je ne comprends donc pas pourquoi la date du 01/12/2007 va me donner une valeur inferieure à celle du 30/11/2007
 

Code :
  1. function verifForm(){
  2. Today = new Date;
  3. Jour = Today.getDate();
  4. Mois = (Today.getMonth())+1;
  5. Annee = Today.getFullYear();
  6. Affiche_date = Jour + "/" + Mois + "/" + Annee;
  7. aujourdhui = getDate(Affiche_date).getTime();
  8. // difference entre les deux dates (date1 doit etre inferieur a date2)
  9. diff = getDate(document.all('date').value).getTime()-getDate(document.all('date2').value).getTime();
  10. diff==0?diff:diff/Math.abs(diff);
  11. if(diff>1){
  12. alert(' date1= '+ getDate(document.all('date').value).getTime() +' \ndate2= '+ getDate(document.all('date2').value).getTime() +' '\ndateD=' + aujourdhui);
  13. return false;
  14. }
  15. }


 
merci de votre aide

Reply

Marsh Posté le 15-11-2007 à 14:29:14   

Reply

Marsh Posté le 15-11-2007 à 14:34:39    

Le bug il est dans l'interface chaise-clavier:

Code :
  1. >>> new Date(2007, 11, 29).getTime()
  2. 1198882800000
  3. >>> new Date(2007, 11, 30).getTime()
  4. 1198969200000
  5. >>> new Date(2007, 12, 1).getTime()
  6. 1199142000000


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed