...

View Full Version : date: change "03" into "March"



Trinity-Links
03-10-2009, 12:49 AM
just a quicky,

If tried a number of ways to turn "03" into "March" & "04" into "april" and so on.........


$date ="03";
$date = strftime("%b", $date);

I'm obviously using the wrong command but I'm balls'd if I can find the right one.


Help 4 a thicky???

oesxyl
03-10-2009, 01:16 AM
just a quicky,

If tried a number of ways to turn "03" into "March" & "04" into "april" and so on.........


$date ="03";
$date = strftime("%b", $date);

I'm obviously using the wrong command but I'm balls'd if I can find the right one.


Help 4 a thicky???
if you don't need to work with date, this will work:


$months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$thismonth = 3;
echo $months[$thismonth-1];


best regards

Iszak
03-10-2009, 01:26 AM
<?php
$month = 03;

echo date('F', mktime(0, 0, 0, $month + 1, 0, 1970)); // March
// OR
echo strftime('%B', mktime(0, 0, 0, $month + 1, 0, 1970)); // March

Don't know why I need to +1, but I do!

Edit: I like this way,


echo strftime('%B', strtotime("$month/1/1970"));

cmancone
03-10-2009, 03:21 AM
You need $month+1 because you set day = 0. Set day=1 and problem solved. Hence why you don't need the $month+1 in your third example.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum