CodeIgniter Forums

Full Version: listing news and events problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Bigil Michael[/eluser]
i want to list news and events like this manner


june 2011
may 2011
april 2011
.
.
.
.
.
july 2010


i dont know how to print months like this can anyone help me??

El Forum

[eluser]vitoco[/eluser]
suposing that your date stored in $date , you can transform that to time using strtotime

http://www.php.net/manual/en/datetime.formats.date.php

in one of the formats accepted, then use the time resulting as second parameter for date() function, and format to using first parameter

http://php.net/manual/en/function.date.php

example
Code:
$date = '2011-01-01' ;
echo date('F Y' , strtotime( $date ) );

Saludos

El Forum

[eluser]Bigil Michael[/eluser]
my aim is not like that

i have date like this in my table

2011-06-01
2011-06-05
2011-06-11
2011-06-15

2011-07-01
2011-07-05
2011-07-11
2011-07-15

i want to print the date like this
june 2011
july 2011

if any date in a month is present then i want to print that month.
i think now you got the problem

can anyone solve my problem??

El Forum

[eluser]jmadsen[/eluser]
so follow the link vitoco posted: http://php.net/manual/en/function.date.php

and put the parameters in the format that match what you are after.


Code:
$date = '2011-01-01' ;
echo date('M Y' , strtotime( $date ) );

After 173 posts, you should start to make an effort to look some things up on your own and try them before calling for help.

El Forum

[eluser]vitoco[/eluser]
I've already solve your problem, and if that isn't enough or you don't get it...well...