echo time();
echo date('Y-m-d H:i:s');
echo date_default_timezone_get();
date_default_timezone_set('Asia/Shanghai'); //设置为上海的时区 echo date('Y-m-d H:i:s');
echo date('Y-m-d H:i:s',time()); echo '<br/>'; echo date('Y-m-d H:i:s',time());
2.JSON格式数据的操作
$arr = array(1,2,5,8,"Hello","CQUT",array("h"=>"Hello","name"=>"CQUT")); echo 'array format => '.'<br/>'; PRint_r($arr); echo '<br/>'; echo 'json formate =>'.'<br/>'; echo json_encode($arr);//json_encode将一个对象转成json格式的数据输出 array format =>
$obj = array('h'=>'Hello','w'=>'World',array(1,2,3)); echo json_encode($obj);输出 {"h":"Hello","w":"World","0":[1,2,3]}
$jsonStr = '{"h":"Hello","w":"World","0":[1,2,3]}'; $obj = json_decode($jsonStr); print_r($obj); echo '<br/>'; echo $obj->h;输出 stdClass Object ( [h] => Hello [w] => World [0] => Array ( [0] => 1 [1] => 2 [2] => 3 ) ) Hello