CodeIgniter Forums
listing news and events problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: listing news and events problem (/thread-42733.html)



listing news and events problem - El Forum - 06-17-2011

[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??


listing news and events problem - El Forum - 06-17-2011

[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


listing news and events problem - El Forum - 06-20-2011

[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??


listing news and events problem - El Forum - 06-20-2011

[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.


listing news and events problem - El Forum - 06-20-2011

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