The lowercase L on the date function is used to display the full name of the day, like Monday. While changing it to d, it will display values or numbers from 1-7 which represents 7 days of the week. Changing it to D will display 3 letters, like for example: Mon, Tue, Wed, Thu, Fri, Sat, Sun.
I use switch statement. But you can also use if...elseif....else statement.
#
<html> <?php $day=Date("l"); echo "<h1>Today is"." ".$day; switch($day) { case 'Monday': echo "<body bgcolor='red'>"; break; case 'Tuesday': echo "<body bgcolor='yellow'>"; break; case 'Wednesday': echo "<body bgcolor='blue'>"; break; case 'Thursday': echo "<body bgcolor='green'>"; break; case 'Friday': echo "<body bgcolor='pink'>"; break; case 'Saturday': echo "<body bgcolor='orange'>"; break; case 'Sunday': echo "<body bgcolor='black'>"; break; } ?> </body> </html>
0 comments:
Post a Comment