Welcome Guest, Not a member yet? Register   Sign In
Difficulty handling returned timestamps from a SQL Query
#1

[eluser]Unknown[/eluser]
Hi,

I have a MySql table that has a DATETIME field. The application inserts data with GMT time stamps. I am having trouble retrieving handling the timestamp variable when its retrieved from the database. I wanted to use the "gm" function to return the timestamp in local time but it wont accept $row->timeStamp as a valid variable.

I guess I am not clear on how PHP handles $row->timestamp. Can someone enlighten me?

Thanks
Wayne


This is part of my controller function:
--------------------------------------
Code:
$sql= 'SELECT SensorData.timeStamp, SensorData.'.$data['channel']
      .' AS value FROM SensorData WHERE device_serial ="'.$data["serial"].'"';

$data['channel']= $this->db->query($sql);
$data['title']= 'Channel Data';
$this->load->view("ch_data_view",$data);

And part of ch_data_view:
-------------------------
Code:
<?php
setlocale(LC_TIME, 'en_US');

foreach ($channel->result() as $row):

$timeStamp= strftime("%b %d %Y %H:%M", $row->timeStamp);?>

<tr><td>&lt;?$timeStamp?&gt;</td><td>&lt;?=$row->value?&gt;</td></tr>

&lt;?php endforeach;?&gt;


Messages In This Thread
Difficulty handling returned timestamps from a SQL Query - by El Forum - 11-15-2008, 09:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB