![]() |
Question about calendar and database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Question about calendar and database (/showthread.php?tid=18388) |
Question about calendar and database - El Forum - 05-05-2009 [eluser]Mef[/eluser] Hi, I've got table with events in my database, where every event has date and time in DATETIME format. What I'm trying to do, is to write a loop, to automatically fill CI's calendar array from db. This is how it looks static: Code: $eventy = array( So basically I assume I need to pull out month and day from DATETIME field, create a loop and change static months, days and IDs to dynamic ones, but I have no idea how to achieve this. Any help will be appreciated. Question about calendar and database - El Forum - 05-05-2009 [eluser]Dam1an[/eluser] You should be able to do this using PHPs date function. Set the date format (the part you want) as the first parameter, and the date (in timestamp format) as the second parameter... That should get you what you want Question about calendar and database - El Forum - 05-05-2009 [eluser]Thorpe Obazee[/eluser] if you have dates in datetime format, you can use strtotime then using what Dam1an suggested, date() Question about calendar and database - El Forum - 05-05-2009 [eluser]opel[/eluser] I have this in my model : Code: function calendarDates($year, $month) And this in my controller : Code: //Get article dates Question about calendar and database - El Forum - 05-05-2009 [eluser]Mef[/eluser] Thanks for replies. Opel, I'll try to adapt your code into my environment, special thanks for you for giving me some clues. |