Ummm, current time where? :)
Assuming you mean your server's time, it shouldn't be too hard, but i
thought I'd point out that your readers/users are bound to be in different
time zones. Whilst some may think "oh, different time zone", others will
probably think "idiots" :)
Then another option would be to do it based on the user's time, but if they
have their clock wrong, same problem.
Anyhoo, I just whipped this up... there is probably 100's of ways of doing
it, but this was the first off the top of my head. Untested code. Returns
"good evening" from 5:00pm > 11:59pm, "good morning" from 12 midnight until
11:59am, and "good afternoon" from 12 midday thru to 4.59pm. I haven't
taken into account daylight savings, timezones or anything else... just real
basic, based on the hours.
<?
function serverTimeGreeting()
{
$h = date('G'); // current hour (0-23)
$greeting = "good evening";
if($h < 17)
{ $greeting = "good afternoon"; }
if($h < 12)
{ $greeting = "good morning"; }
return $greeting;
}
echo serverTimeGreeting();
?>
Justin
on 03/09/02 9:01 PM, Javier Montserat ([EMAIL PROTECTED]) wrote:
> really simple one -
>
> does someone have a bit of code that will variously display 'good morning',
> 'good afternoon', 'good evening' based on the current time?
>
> good morning from london,
>
> Javier
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php