Re: time of day

From: Date: Fri, 04 Oct 2002 02:49:14 +0000
Subject: Re: time of day
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-118797@lists.php.net to get a copy of this message
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; }

« previous php.general (#118797) next »