php 操作时间、日期类函数
<?php // time() echo "time(): ",time(); echo "\n"; // strtotime() echo "strtotime(): ",strtotime('1991-09-26'); echo "\n"; // date($format, $timestamp),format为格式、timestamp为时间戳--可填参数。第二个参数很有用,容易忘记 echo "date('Y-m-d H:i:s'): ",date('Y-m-d H:i:s'); echo "\n"; // 和缺省time()第二个参数一样 echo date('Y-m-d', time()); echo "\n"; // strtotime的巧用 例如获取第二天这个日期时间 echo date('Y-m-d H:i:s', strtotime('+1 day')); echo "\n"; echo date('Y-m-d H:i:s', strtotime('-1 day')); echo "\n";