1. Time and date
- How to get timestamp time ()-Number of milliseconds since 1970
echo Time ();
echo Date ('y-m-d h:i:s');
- Get the default time zone
Echo Date_default_timezone_get ();
- The default time is not the same as the local computer time, you need to set the appropriate time zone
Date_default_timezone_set ('asia/shanghai'// set to Shanghai's time zone echo Date ('y-m-d h:i:s');
- Convert the timestamp into a date.
echo Date ('y-m-d h:i:s'<br/>'; Echo date ('y-m-d h:i:s', Time ());
operation of 2.JSON format data
Arrays can be nested (arrays containing arrays) can also contain objects (values and names correspond to internal data, key-value pairs) [1,2,5,7,8, "Hello", [6,7,8],{"H", "Hello"}] {"H": "Hello", "W": "World", [ [+]}
- Arrays generate JSON-formatted data encode
$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 to convert an object to JSON-formatted data
Output array format = =
Array ([0] = 1 [1] = 2 [2] = 5 [3] = 8 [4] = = [5] = = Cqut [6] + = Array ([h] = = [ Name] = Cqut))
JSON formate = [1,2,5,8, "Hello", "Cqut", {"H": "Hello", "name": "Cqut"}]
- Object generates JSON-formatted data encode
$obj Array (' h ' = ' Hello ', ' w ' = ' world ',array(+/-)); echo json_encode ($obj);
Output {"H": "Hello", "W": "World", "0": [All-in-all]}
- Convert JSON-formatted data to PHP objects decode
$jsonStr = ' {' h ': ' Hello ', ' W ': ' World ', ' 0 ': [[+]} '; $obj = Json_decode ($jsonStr); Print_r ($obj); Echo ' <br/> '; Echo $obj->h;
Output StdClass Object ([h] = = Hello [W] = [0] = = Array ([0] = 1 [1] = 2 [2] = 3)) Hello
PHP Common Library functions