Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Zmiana funkcji wyświetlania daty dodania posta na dwunastogodzinną.
Nick
post 22.06.2009, 18:06:16
Post #1





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 28.12.2008

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


Witajcie!
Mam dwa problemy z funkcją odpowiedzialną za wyświetlanie daty dodania posta na Forum. Pierwsza z nich polega na tym, że jeżeli na przykład napisze posta o 19:20 o godzinie 03:00 następnego dnia wyświetlany jest napis "dzisiaj o 19:20". Dopiero o godzinie 19:20 zmienia się to na "wczoraj o 19:20". Czyli, krótko mówiąc dzień dodania posta zmienia się po 24 godzinach od jego dodania.

Innym problem, jest to, że mam dwunastogodzinny datę, co na polskiej stronie jest trochę irytujące. A oto funkcja odpowiedzialna za wyświetlanie daty postów na forum:
Kod
        function timePassed($time, $showtime = 1) {
         global $locale, $settings;
         $mode = "short";
         $timepassed = (time () - $time);
         if ($timepassed > 7 * 24 * 3600) {
             if($timepassed > 14 * 24 * 3600){
                 $timesince = showdate ( "%d-%m-%Y", $time );
             } else {
                 $timesince = floor ( $timepassed / (7 * 24 * 3600) );
                 $timesince .= ($timesince != "1" ? $locale ['fb980'] : $locale ['fb981']);
             }
         } elseif ($timepassed >= 24 * 3600 && $timepassed <= 48 * 3600 && $mode == "short"){
             $timesince = $locale['fb2_101'];
         } elseif ($timepassed <= 24 * 3600 && $mode == "short"){
             $timesince = $locale['fb2_100'];
         } elseif ($timepassed > 2 * 24 * 3600 && $mode == "short"){
             $timesince = floor ( $timepassed / (24 * 3600) );
             $timesince .= ($timesince != "1" ? $locale ['fb982'] : $locale ['fb983']);
         } elseif ($timepassed > 24 * 3600 && $mode !== "short") {
             $timesince = floor ( $timepassed / (24 * 3600) );
             $timesince .= ($timesince != "1" ? $locale ['fb982'] : $locale ['fb983']);
         } elseif ($timepassed > 3600 && $mode !== "short") {
             $timesince = floor ( $timepassed / 3600 );
             $timesince .= ($timesince != "1" ? $locale ['fb984'] : $locale ['fb985']);
         } elseif ($timepassed > 0 && $mode !== "short") {
             $timesince = floor ( $timepassed / 60 );
             $timesince .= ($timesince != "1" ? $locale ['fb986'] : $locale ['fb987']);
         } else {
             $timesince = showdate ( "%d-%m-%Y", $time );
         }
         if ($showtime || $mode == "short")
             $timesince .= "&nbsp;<span class='tbl2'>" . strftime ( "%I:%M %p", ($time + ($settings ['timeoffset'] * 3600)) ) . "</span>";
         return $timesince;
     }
Go to the top of the page
+Quote Post
kefirek
post 22.06.2009, 18:50:57
Post #2





Grupa: Zarejestrowani
Postów: 781
Pomógł: 256
Dołączył: 29.06.2008

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


  1. <?php
  2. function timePassed($time, $showtime = 1) {
  3.        return "<span class='alt'>".showdate("%d.%m.%Y %H:%M:%S", $time)."</span>";
  4.    
  5.    }
  6. ?>
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 10:12