Days Of The Week - PHP Code help

Started on the old forum in October 2011 · view the original in the archive · old links redirect here

2 replies · 380 views · started 15 years ago · 1 min read

3 participants
K9 Conceptz Newbie · 3 posts #1

Hi guys, I wanted help in getting the days of the week displayed as below:

<?php
$D=date("D")
if ($D==sun)
{
echo "Have a good sunday";
}
else if ($D==sat)
{
echo "Have a good weekend";
}
else if ($D==fri)
{
echo "Have a good day";
}
?>

and I would like it to be something like:

Monday - echo date("D") Tuesday - echo date ("D") + 1 Wednesday - echo date ("D") + 2 etc etc.

Thanks

sladex Developer · 232 posts #2
<?php $d=date("D"); if ($d=="Mon") echo "Aloha Monday"; if ($d=="Tue") echo "Hi Tuesday"; if ($d=="Wed") echo "Hi Wen!"; if ($d=="Thu") echo "Hi Thu!!"; if ($d=="Fri") echo "Hi Friday"; if ($d=="Sat") echo "Hi Saturday"; if ($d=="Sun") echo "Hi Sunday"; ?>
CreativityKills Lead · 833 posts #3
function greeting()
{
$wkdays = array('mon', 'tue', 'wed', 'thu', 'fri');
$wkend = array('sat', 'sun');

if (date('D') === 'Fri')
return 'TGIF!';

if (in_array(strtolower(date('D')), $wkdays))
return 'Hello there, its '.date('l');

return 'Have an awsome weekend!';
}

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close