chris666uk1 Posted November 17, 2011 Share Posted November 17, 2011 please could some one help me i need to limit the query by timestamp for the last 7 days here is my code on the php side <?php $db = @mysql_connect("localhost", "8conv", "*****") or die("Connection Error: " . mysql_error()); mysql_select_db("tempmonitor") or die("Error connecting to db."); $sql = "SELECT *, UNIX_TIMESTAMP(datetime) AS datetime FROM 8conv"; $result = mysql_query($sql); $data = array(); while ($row = mysql_fetch_array($result)) { $temp1[] = array($row['datetime'] * 1000, (int)$row['temp1']);; } $temp1 = json_encode($temp1); Link to comment https://forums.phpfreaks.com/topic/251318-please-help-limit-unix_timestamp-by-last-7-days/ Share on other sites More sharing options...
The Little Guy Posted November 17, 2011 Share Posted November 17, 2011 SELECT *, UNIX_TIMESTAMP(datetime) AS datetime FROM 8conv where datetime > date_sub(now(), interval 7 day) Link to comment https://forums.phpfreaks.com/topic/251318-please-help-limit-unix_timestamp-by-last-7-days/#findComment-1288968 Share on other sites More sharing options...
xyph Posted November 17, 2011 Share Posted November 17, 2011 http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html Link to comment https://forums.phpfreaks.com/topic/251318-please-help-limit-unix_timestamp-by-last-7-days/#findComment-1289014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.