Wade Smart wrote:
> Tedit kap wrote:
>> Hi,
>> I would like to modify the dae display format, for the dates stored in my
>> database.
>> It is stored like this: 2008-07-01
>> I want to print as: July, 1st
>> Now I wrote something as below, but it displays Dec 31st instead of July
>> 1st. (And in my database Dec31 is nowhere anyway). Please tell me how to fix.
>> Here is the relevant part of code:
>> while ($row = mysql_fetch_array($query)) {
>> $c1=$row['date'];
>> $c=date('F jS',$c1);
>> echo"<p class='title1'>" . $c."<br/>". $row['title'] . "</p>" ; }
>> Thanks
>
> 20080712 1555 GMT-6
>
> What I would do is, get each of the three parts and put them in a variable:
> $y = "2008";
> $m = "07";
> $d = "01";
>
> and then using mktime you could format it properly.
>
> Wade
20080712 1606 GMT-6
Sorry, forgot to post the code:
$date = "2008-07-01";
$m = substr($date1, 0, 4);
$d = substr($date1, 5, 2);
$y = substr($date1, 9, 2);
$date_formatted = date("M d Y", mktime(0,0,0, $m, $d, $y));
Wade