Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [funkcja]ile minut?
marast78
post
Post #1





Grupa: Zarejestrowani
Postów: 176
Pomógł: 0
Dołączył: 30.11.2004

Ostrzeżenie: (0%)
-----


ok mam czas w formacie 08:00:00 i 09:30:00 JAK w php obliczyć ilośc minut między nimi ma ktoś jakąś funkcje a moze taka juz jest (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) pliss help me (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

Ten post edytował marast78 27.03.2005, 14:28:53
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
mike
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

Ostrzeżenie: (0%)
-----


Cytat(Tiraeth @ 2005-03-27 15:20:49)
funkcja:
  1. <?php
  2. function countTime($a, $b, $type)
  3. {
  4.    $at = strtotime($a);
  5.    $bt = strtotime($b);
  6.    $czas = $bt-$at;
  7.    if($czas < 0) { $czas*=-1; }
  8.    if($type == 'sec')
  9.    {
  10.       return($czas);
  11.    }
  12.    elseif($type == 'min')
  13.    {
  14.       return($czas/60);
  15.    }
  16.    elseif($type == 'godz')
  17.    {
  18.       return($czas/3600);
  19.    }
  20.    else
  21.    {
  22.       return false;
  23.    }
  24. }
  25. ?>

Ja tylko mam uwagę odnoścnie linii 6 i 7:
abs() (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 11.10.2025 - 23:31