PHP 时间问题处理与获取

        //php获取格林威治标准时间错误问题 北京时间差了正好8个小时:
        //文件头加载此函数 PRC代表中国:date_default_timezone_set("PRC");
        //修改php.ini文件    默认 ;date.timezone =   修改为 date.timezone = PRC

        echo date("Y-m-d H:i:s", strtotime("-1 day"));         //前一天时间

        echo date("Y-m-d H:i:s", strtotime("-1 month"));       //前一月时间

        echo date("Y-m-d H:i:s", strtotime("-1 year"));        //前一年时间

        echo strtotime(date('Y-m-d H:0:0', time()));           //当天时间整点时间戳
        
        echo strtotime(date('Y-m-d', time()));                 //当天凌晨时间戳

猜你喜欢

转载自blog.csdn.net/qq_24909089/article/details/79852045