Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
proteklo vrijeme

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
Gale



Joined: 04 Apr 2005
Posts: 120

PostPosted: 13.04.2005 22:24    Post subject: proteklo vrijeme Add user to your forum ignore list Reply with quote

Da li ima tko možda kod U PHP-u, za prikaz proteklog vremena u ... danima, minutama, sekundama, od određenog datuma.

Slično kao i ovdje na vijestima.
Back to top
View user's profile Send private message Visit poster's website
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 14.04.2005 15:54    Post subject: Add user to your forum ignore list Reply with quote

Code:
function hr_oblik($n,$a='',$b='',$c=''){
   if(is_nan($n)) return false;
   
   if($n < 5 || $n > 20){
      $mod = $n%10;
      if($mod == 1) return $a;
      else if($mod < 5) return $b;
   }
   return $c;
}

function parseDate($date = null,$datestring = 'j.n.Y. \u H:i'){
   if(!$date || $date == '0000-00-00 00:00:00') return false;
   
   if(is_int($date)) $t = $date;
   else if(($t = strtotime($date)) === -1) return $date;
   $d = time() - $t;
   
   if($d<60) return "prije $d sekund" . hr_oblik($d,'u','e','i');
   $d = floor($d/60);
   if($d<60) return "prije $d minut" . hr_oblik($d,'u','e','a');
   $d = floor($d/60);
   if($d<24) return "prije $d sat" . hr_oblik($d,'','a','i');
   $d = floor($d/24);
   if($d<7) return "prije $d dan" . hr_oblik($d,'','a','a');
   
   return date($datestring,$t);
}

funkciji parseDate() kao argumente daj timestamp (pazi da bude tipa integer) ili datum (string dozvoljen kao ulaz funkcije strtotime(), opisan ovdje) i (optional) string za ispis datuma (date() funkcija) ako je vremensko razdoblje duže od 7 dana.

Počeo sam ju pisati za svoje potrebe, sad kad si već pitao sam završio. Budi ohrabren da proučiš i modificiraš po želji.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Gale



Joined: 04 Apr 2005
Posts: 120

PostPosted: 14.04.2005 17:00    Post subject: Add user to your forum ignore list Reply with quote

puno ti hvala, sad ću da isprobam!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group