You are here: Re: Help me fix my "x minutes ago" time script please :) « PHP Programming Language « IT news, forums, messages
Re: Help me fix my "x minutes ago" time script please :)

Posted by gosha bine on 04/17/07 19:32

JamesG wrote:

>
> Thanks so much for correcting the silly mistake.
> I also hate nested elseifs but in this case it's the only way to do it
> I think-- I considered a switch statement but that isn't useful in
> this instance.
>
>
>

you actually don't need else's here, because you return in every branch.
Just use ifs:

if($ts < 60)
return $ts . " seconds ago";
if($ts < (60 * 60))
return intval($ts / 60) . " minutes ago";

etc


--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация