
正文
PHP的日期和时间
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
<?php//2.获取日期和时间//时间是一维的,所以任何一个时间的时间戳都是不一样的//array getdate([int timestamp]);//string date(string format[,int timestamp])/*Y: 四位数年m: 月01-12 带0n: 月1-12d: 天01-31 带0j: 天1-31H: 24小时制h: 12小时制i: 分钟00-59s: 秒00-59w: 星期几0-6A: 上午AM或下午PMa: 上午am或下午pm修改默认时区方法一:修改配置文件 date.timezone = Etc/GMT+8方法二:date_default_timezone_set("PRC"); //设置中国时区 date_default_timezone_get(); //获取当前时区*/echo time(); //输出当前时间的时间戳echo "<br />";//时分秒 月日年echo date("Y-m-d H:i:s", mktime(1, 30, 30, 5, 15, 2007));echo "<br />";echo strtotime("now"); //now表示当前的时间戳,就是获取参数对应的时间戳echo "<br />";echo strtotime("+1 day");echo "<br />";echo date("Y-m-d H:i:s", strtotime("5-10-2014 12:30:30"));echo "<br />";$arr = getdate(); //其参数有哪些?返回现在时间的日期信息数组echo "<pre>";print_r($arr);echo "</pre>";echo "<br />";echo date("Y-m-d H:i:s"); //格式化时间函数,不传参数,表示格式化当前时间echo "<br />";echo microtime(); //返回当前的精确到毫秒数时间戳echo microtime(true); //以浮点型的形式返回当前的时间戳?>







