【发布时间】:2013-06-04 15:46:17
【问题描述】:
我必须创建一个包含每行日期/时间的数组。 我正在使用以下代码。 “TIME_STAMP”是包含 MySQL 时间戳的字段(默认为 CURRENT_TIMESTAMP)。
while ( $row = mysql_fetch_array($result) )
{
$timestamp = strtotime($row["TIME_STAMP"]);
$x[] = sprintf("%s, %s", date ('j/n', $timestamp), date('H:i', $timestamp));
}
如果我从 mysql 客户端进行 SELECT * 一切正常:TIME STAMP 是正确的:
2013-06-04 17:11:43
但是当我将这个数组传递给 JpGraph(制作水平轴)时,所有记录都显示为
1/1 01:00
图表代码:
$graph = new Graph("1024", "800");
$graph->SetScale( 'textlin');
$graph->img-> SetMargin(60,40,40,110);
$graph->xaxis->SetTickLabels( $x );
$graph->xgrid->Show(true);
有什么提示吗?
【问题讨论】:
-
如果你直接在第 3 行之前
echo $row["TIME_STAMP"];会得到什么? -
给我空白....发生了什么事?
-
你100%确定表的列名是
TIME_STAMP吗?
标签: php mysql date timestamp jpgraph