Posted By

olive on 08/22/06


Tagged

date


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Ernstladen


Fonctions dates


 / Published in: PHP
 

  1. // Affichage d'une chaine de la forme YYYYMMJJ
  2. sprintf("%02d/%02d/%04d", substr($date,6,2), substr($date,4,2), substr($date,0,4));
  3. // Chaine YYYYMMJJ representant la date
  4. $date_courante = date("YmdHis", time());
  5. // Chaine YYYYMMJJ representant la date d'hier
  6. $date=date("Ymd", mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
  7.  
  8. //h:m:s entre 2 dates
  9. $time_submitted=mktime(substr($bug["date_submitted"],11,2),substr($bug["date_submitted"],14,2),substr($bug["date_submitted"],17,2),substr($bug["date_submitted"],5,2),substr($bug["date_submitted"],8,2),substr($bug["date_submitted"],0,4));
  10. $time_resolved=mktime(substr($bug["date_resolved"],11,2),substr($bug["date_resolved"],14,2),substr($bug["date_resolved"],17,2),substr($bug["date_resolved"],5,2),substr($bug["date_resolved"],8,2),substr($bug["date_resolved"],0,4));
  11. $bug["time_to_resolve"]=calcul_hours($time_resolved-$time_submitted);
  12.  
  13. function calcul_hours($temps)
  14. {
  15. //combien d'heures ?
  16. $hours = floor($temps / 3600);
  17.  
  18. //combien de minutes ?
  19. $min = floor(($temps - ($hours * 3600)) / 60);
  20. if ($min < 10)
  21. $min = "0".$min;
  22.  
  23. //combien de secondes
  24. $sec = $temps - ($hours * 3600) - ($min * 60);
  25. if ($sec < 10)
  26. $sec = "0".$sec;
  27.  
  28. return $hours."h".$min."m".$sec."s";
  29. }

Report this snippet  

You need to login to post a comment.