pouncer Posted November 8, 2006 Share Posted November 8, 2006 im looking for a snippet that will echo Good morning!Good afternoon!Good evening!depending on the time. anyone got any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/26630-looking-for-a-php-script/ Share on other sites More sharing options...
Caesar Posted November 8, 2006 Share Posted November 8, 2006 We typically don't use these boards for anything other than helping to troubleshoot existing code.Try to look into PHP's time() function and do some reading on conditional statements. Quote Link to comment https://forums.phpfreaks.com/topic/26630-looking-for-a-php-script/#findComment-121792 Share on other sites More sharing options...
redbullmarky Posted November 8, 2006 Share Posted November 8, 2006 [url=http://uk2.php.net/time]time()[/url] will do the job. [url=http://uk2.php.net/date]date()[/url] will do the job too, probably easier. as i'm generous:[code]<?php// get the current hour (24hr format)$hour_of_day = date('H');$output = 'Good ';if ($hour_of_day < 12) // 12pm{ $output .= 'morning';}elseif ($hour_of_day < 17) // 5pm{ $output .= 'afternoon';}else{ $output .= 'evening';}echo $output;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/26630-looking-for-a-php-script/#findComment-121797 Share on other sites More sharing options...
pouncer Posted November 8, 2006 Author Share Posted November 8, 2006 perfect. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/26630-looking-for-a-php-script/#findComment-121857 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.