PDA

View Full Version : show some code based on the day of the month.



chetanmadaan
10-03-2011, 04:22 PM
I currently use this php code of few lines to display text based on the day of week.



$today = date("l");

switch ($today) {
case "Monday" :
$today = $monday;
$todaylink = $mondaylink;
break;
case "Tuesday" :
$today = "$tuesday";
$todaylink = $tuesdaylink;
break;
case "Wednesday" :
$today = $wednesday;
$todaylink = $wednesdaylink;
break;
case "Thursday" :
$today = "$thursday";
$todaylink = $thursdaylink;
break;
case "Friday" :
$today = "$friday";
$todaylink = $fridaylink;
break;
case "Saturday" :
$today = $saturday;
$todaylink = $saturdaylink;
break;
case "Sunday" :
$today = "$sunday";
$todaylink = $sundaylink;
break;

}

echo $today;

i want to change this to the day of the month??? is this possible with some php code and javascript modifications here and there.

rangana
10-03-2011, 06:30 PM
It might be best to point you into the right direction.

First, date("l"); in your script gets the date's day in a full textual representation of the day of the week. So if today is Tuesday (based on your server's time), it will return "Tuesday". With that said, you just need to change the "l" parameter into F. Check this link for more info:
http://php.net/manual/en/function.date.php

From there, you can update your switch cases to match what you're trying to do.


Hope that helps.

chetanmadaan
10-03-2011, 06:51 PM
like always... THANK YOU!

i love DD.