Welcome Guest, Not a member yet? Register   Sign In
Unix Timestamp Searching
#1

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

[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();
#3

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

[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")
Otherwise the single quotes are removed.




Theme © iAndrew 2016 - Forum software by © MyBB