Welcome Guest, Not a member yet? Register   Sign In
MySQL Timezone/Date Question?
#1

[eluser]BobbyB[/eluser]
Hello,
I have a problem getting the newest articles from my database.
I try to get the number of news articles from the last 24 hours.
The date is stored in the database as "datetime".
I am using:
Code:
$query = $this->db->query('SELECT * FROM twitter_news WHERE tw_created_at >= DATE_SUB(CURRENT_DATE, INTERVAL 24 HOUR)');
$data['count_new'] = $query->num_rows();
I figured that the timezone setting of the mysql server might be different, so I tried to change the interval accordingly.
But it doesn't work.
I tried changing it to
Code:
INTERVAL 3 HOUR

and the query is still giving me some items that are older than 24 hours?
How can I check what "CURRENT_DATE" is returning?
Any hints?
In a view of mine I use:
Code:
$now = time();
$unix1 = human_to_unix($tweet['tw_created_at']);
$timespan = $now-$unix1;
//
if($timespan < 86400){...
And it works great as expected - but not in my SQL query :-S
Thanks in advance!


Messages In This Thread
MySQL Timezone/Date Question? - by El Forum - 03-17-2010, 02:46 PM
MySQL Timezone/Date Question? - by El Forum - 03-17-2010, 03:11 PM
MySQL Timezone/Date Question? - by El Forum - 03-18-2010, 04:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB