![]() |
Unix Timestamp Searching - 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: Unix Timestamp Searching (/showthread.php?tid=8136) |
Unix Timestamp Searching - El Forum - 05-06-2008 [eluser]pgsjoe[/eluser] So I thought I had an idea of how to do this, but now I'm just lost. I've got my submitDate field in my database as a Unix Timestamp. But now, I need to search for submissions that are only from April. So how do I search a Unix Timestamp for a month, when it's not written as 04 in the timestamp? Thanks in advance. Unix Timestamp Searching - El Forum - 05-06-2008 [eluser]xwero[/eluser] with mysql you can do Code: $this->db->select('id,date')->from('table')->where('FROM_UNIXTIME(date,'%c')',4)->orderby('date')->get(); Unix Timestamp Searching - El Forum - 05-07-2008 [eluser]pgsjoe[/eluser] Ohhhh, that is awesome! Exactly what I needed to know that I didn't even know existed. Thanks a ton. Though, what does the %c mean? Unix Timestamp Searching - El Forum - 05-07-2008 [eluser]xwero[/eluser] it is the numeric representation of the month without the prefixed zero. But you have to write the where parameters as Code: ->where("FROM_UNIXTIME(date,'%c') = 4") |