Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php]wiek w sekundach.
pliq
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 9.01.2007
Skąd: /root

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


Witam mam małe zapytania, mianowicie znalazłem skrypt liczący dni, godziny, minuty oraz sekundy od danego dnia, wygląda tak:
  1. <?php
  2.  
  3. function formatetimestamp($until){
  4.  
  5.  $now = time();
  6.  $difference = $until - $now;
  7.  
  8.  $days = floor($difference/86400);
  9.  $difference = $difference - ($days*86400);
  10.  
  11.  $hours = floor($difference/3600);
  12.  $difference = $difference - ($hours*3600);
  13.  
  14.  $minutes = floor($difference/60);
  15.  $difference = $difference - ($minutes*60);
  16.  
  17.  $seconds = $difference;
  18.  $output = "$days dni, $hours godzin, $minutes minut i $seconds sekund.";
  19.  
  20.  return $output;
  21.  
  22. }
  23.  
  24. //int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year 
    [, int is_dst]]]]]]] )
  25.  
  26. echo formatetimestamp(mktime(0,0,0,0,0,0)); //output: e.g "You have to wait 162 Days, 4 Hours, 38 Minutes and 46 Seconds until this Da
    y"
  27.  
  28. ?>

i chciałbym aby wiek był podany w sekundach, jak to zrobić ?
pozdrawiam i dziękuję.

Ten post edytował pliq 10.01.2007, 00:37:19
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kriqs
post
Post #2





Grupa: Zarejestrowani
Postów: 148
Pomógł: 0
Dołączył: 31.05.2006

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


  1. <?php
  2.  
  3. function formatetimestamp($until){
  4.  
  5.  $now = time();
  6.  $difference = $until - $now;
  7.  
  8.  $wiekWsec = $difference;
  9.  
  10.  $days = floor($difference/86400);
  11.  $difference = $difference - ($days*86400);
  12.  
  13.  $hours = floor($difference/3600);
  14.  $difference = $difference - ($hours*3600);
  15.  
  16.  $minutes = floor($difference/60);
  17.  $difference = $difference - ($minutes*60);
  18.  
  19.  $seconds = $difference;
  20.  $output = $days.' dni, '.$hours.' godzin, '.$minutes.' minut i '.$seconds.' sekund. Wiek w sekundach '.$wiekWsec;
  21.  
  22.  return $output;
  23.  
  24. }
  25.  
  26. //int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year 
    [, int is_dst]]]]]]] )
  27.  
  28. echo formatetimestamp(mktime(0,0,0,0,0,0)); //output: e.g "You have to wait 162 Days, 4 Hours, 38 Minutes and 46 Seconds until this Da
    y"
  29.  
  30. ?>


powinien dzialac aczkolwiek nie sprawdzalem (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: 4.10.2025 - 22:13