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 ', Time ()), Echo ' <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/> ';p rint_r ($arr); Echo ' <br/> '; echo ' json formate = '. ' <br/> '; Echo json_encode ($arr);//json_encode 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 ': [[n] '; $obj = Json_decode ($jsonStr);p rint_r ($obj); Echo ' <br/> '; Echo $obj->h;
Output StdClass Object ([h] = = Hello [W] = [0] = = Array ([0] = 1 [1] = 2 [2] = 3)) Hello
PHP's common library of functions