Bomgardner, Mark A wrote:
I am trying to format the month portion of a date that I am trying to
pull from MySQL to be placed into a drop down menu to modify the date.
I have tried several ways and none seem to be working. I am pulling the date out of MySQL with: $sDate = explode("-", $row_events['Sdate']);

And then attempting to insert each portion of the array into a drop down
menu with:
echo "<select name=Smonth>";
echo "<option selected>$sDate[1]</option>";
which is where I am running into the problem.  I pull out the month as 2
digit numeric 01, 02, 03 etc., but I want it displayed as January,
February, March, etc.,

I have tried the following with no success:
Date("F",strtotime($sDate)); Strftime("%B:,$sDate);

I would use MySQL to format the date, but I have three date fields to
modify and it would be easier to do it in PHP

Any pointers would be appreciated.

Mark Bomgardner
Technology Specialist

make a function like this:

function datenum2str($date)
        $newdate = str_replace("01","Jan",$date);
        $newdate = str_replace("02","Feb",$date);
        $newdate = str_replace("03","Mar",$date);
        $newdate = str_replace("04","Apr",$date);
        $newdate = str_replace("05","May",$date);
        $newdate = str_replace("06","Jun",$date);
        $newdate = str_replace("07","Jul",$date);
        $newdate = str_replace("08","Aug",$date);
        $newdate = str_replace("09","Sep",$date);
        $newdate = str_replace("10","Oct",$date);
        $newdate = str_replace("11","Nov",$date);
        $newdate = str_replace("12","Dec",$date);

        return $newdate;

And then use this:

echo "<select name=Smonth>";
echo "<option selected value=\"$sDate[1]\">$newdate</option>";

Hope it helps,

El Bekko

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to