SELECT UNIX_TIMESTAMP(datetime_column) as unix_timestamp FROM table ORDER BY datetime_column DESC.
$query = "SELECT * FROM (SELECT * FROM outside ORDER BY id DESC LIMIT $limit) AS foo ORDER BY id ASC"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $dataset1[] = array(($row['unixtime'] * 1000 ),$row['temperature']); }