Re: [PHP] time of day

2002-10-03 Thread Michael Sims

On Thu, 3 Oct 2002 14:43:37 -0700 (PDT), you wrote:

>Hello,
>
>I was wondering if anyone has a good example of a way to do this. Kinda
>lame, but like if the time is between 8am and 12pm, say "good morning",
>between 12pm and 6pm, say good afternoon, and so on.
>
>I know this is probably pretty trivial, but I just wanted to see what
>ideas where out there.

How about this:

function getgreetingtime() {

  $hour = date("G");

  switch(true) {
case($hour < 12):
  $time = "morning";
  break;
case($hour >= 12 && $hour < 18):
  $time = "afternoon";
  break;
case($hour >= 18):
  $time = "evening";
  break;
  }

  return $time;

}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] time of day

2002-10-03 Thread Kevin Stone

PHP can give you the server time, but for this I think it would be better to
have the user's local time, in which case Javascript would provide a better
solution.
-Kevin

- Original Message -
From: "Bryan Koschmann - GKT" <[EMAIL PROTECTED]>
To: "PHP General" <[EMAIL PROTECTED]>
Sent: Thursday, October 03, 2002 3:43 PM
Subject: [PHP] time of day


> Hello,
>
> I was wondering if anyone has a good example of a way to do this. Kinda
> lame, but like if the time is between 8am and 12pm, say "good morning",
> between 12pm and 6pm, say good afternoon, and so on.
>
> I know this is probably pretty trivial, but I just wanted to see what
> ideas where out there.
>
> Thanks in advance!
>
> Bryan
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php