sandyman Posted March 7, 2017 Share Posted March 7, 2017 (edited) <?php$t = date("H");if ($t < "20") { echo "Have a good day!";} else { echo "Have a good night!";}?> what is that date("H") Edited March 7, 2017 by sandyman Quote Link to comment https://forums.phpfreaks.com/topic/303370-please-explain-me-the-code/ Share on other sites More sharing options...
Jacques1 Posted March 7, 2017 Share Posted March 7, 2017 (edited) It's an IQ test. Edited March 7, 2017 by Jacques1 1 Quote Link to comment https://forums.phpfreaks.com/topic/303370-please-explain-me-the-code/#findComment-1543849 Share on other sites More sharing options...
cyberRobot Posted March 7, 2017 Share Posted March 7, 2017 You could check the manual. http://php.net/manual/en/function.date.php Quote Link to comment https://forums.phpfreaks.com/topic/303370-please-explain-me-the-code/#findComment-1543866 Share on other sites More sharing options...
Mlaaa Posted March 7, 2017 Share Posted March 7, 2017 <?php$t = date("H"); if ($t < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; } ?> what is that date("H") <?php // date H is display a hour in a 24 hour format 20:00 $t = date("H"); // so if Hour $t is lesser than 20:00 display message "have a good day" 00:00 - 19:59 if ($t < "20") { // display this message until 20:00 h echo "Have a good day."; } else { // time is now 20:00+ echo "Have a good night."; } ?> 2 Quote Link to comment https://forums.phpfreaks.com/topic/303370-please-explain-me-the-code/#findComment-1543898 Share on other sites More sharing options...
ginerjm Posted March 8, 2017 Share Posted March 8, 2017 I liked Jacques answer better! Quote Link to comment https://forums.phpfreaks.com/topic/303370-please-explain-me-the-code/#findComment-1543926 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.