header("Content-type:text/html;charset=utf-8");
//程序运行时间
$starttime = explode(' ',microtime());
/*········以下是代码区·········*/
$link = mysql_connect("localhost","root","root");
mysql_select_db("test");
mysql_query("set names utf8");
$sql = "select add_time from t1 limit 100000";
$res = mysql_query($sql,$link);
$num = mysql_num_rows($res);
while($row = mysql_fetch_array($res)){
//echo date("Y-m-d H:i",$row['add_time'])." | ";
}
/*········以上是代码区·········*/
//程序运行时间
$endtime = explode(' ',microtime());
$thistime = $endtime[0]+$endtime[1]-($starttime[0]+$starttime[1]);
$thistime = round($thistime,3);
echo '本次通过 PHP 中 date("Y-m-d H:i",$row["add_time"]) 转换。
转换本次转换 '.$num.' 条数据。
本次执行耗时:'.$thistime.' 秒。';
//--------------------------------------------------------
//--------------------------------------------------------
//程序运行时间
$starttime = explode(' ',microtime());
/*········以下是代码区·········*/
$sql = "select add_time from t1 limit 100000";
$res = mysql_query($sql,$link);
$num = mysql_num_rows($res);
while($row = mysql_fetch_array($res)){
echo $row['add_time']." | ";
}
/*········以上是代码区·········*/
//程序运行时间
$endtime = explode(' ',microtime());
$thistime = $endtime[0]+$endtime[1]-($starttime[0]+$starttime[1]);
$thistime = round($thistime,3);
echo '本次直接输出,没任何转换
本次执行耗时:'.$thistime.' 秒。';
//--------------------------------------------------------
//--------------------------------------------------------
//程序运行时间
$starttime = explode(' ',microtime());
/*········以下是代码区·········*/
$sql = "select FROM_UNIXTIME( add_time, '%Y-%m-%d %H:%m' ) as add_time from t1 limit 100000";
$res = mysql_query($sql,$link);
$num = mysql_num_rows($res);
while($row = mysql_fetch_array($res)){
//echo $row['add_time']." | ";
}
/*········以上是代码区·········*/
//程序运行时间
$endtime = explode(' ',microtime());
$thistime = $endtime[0]+$endtime[1]-($starttime[0]+$starttime[1]);
$thistime = round($thistime,3);
echo '本次通过 mysql 中 FROM_UNIXTIME( add_time, "%Y-%m-%d %H:%m" ) 转换。
转换本次转换 '.$num.' 条数据。
本次执行耗时:'.$thistime.' 秒。';
?>