php strtotime()处理时间

来源:互联网 发布:python与量化交易 编辑:程序博客网 时间:2024/05/05 20:51



$day = date("Y-m-d"); //今天            $startDa = strtotime($day.' 00:00:00');//一天的开始            $endDa = strtotime($day.' 23:59:59');//一天的结束            $firstlyDa = strtotime(date("Y-m-01").' 00:00:00');//一个的开始            $finallyDa = strtotime(date("Y-m-t").' 23:59:59');//一个月的结束            echo "今天:".date("Y-m-d H:i:s",strtotime("now",$startDa)), "<br>";            echo "今天:".date("Y-m-d H:i:s",strtotime("now",$endDa)), "<br>";            echo "昨天:".date("Y-m-d H:i:s",strtotime("-1 day",$startDa)), "<br>";            echo "昨天:".date("Y-m-d H:i:s",strtotime("-1 day",$endDa)), "<br>";            echo "本周:".date("Y-m-d H:i:s",strtotime("Monday")), "<br>";            echo "本周:".date("Y-m-d H:i:s",strtotime("Sunday 23 hours 59 minutes 59 seconds",$endDa)), "<br>";            echo "上周:".date("Y-m-d H:i:s",strtotime("last Monday",$startDa)), "<br>";            echo "上周:".date("Y-m-d H:i:s",strtotime("last Sunday 23 hours 59 minutes 59 seconds")), "<br>";            echo "本月:".date("Y-m-d H:i:s",strtotime("now",$firstlyDa)), "<br>";            echo "本月:".date("Y-m-d H:i:s",strtotime("now",$finallyDa)), "<br>";            echo "上月:".date("Y-m-d H:i:s",strtotime("-1 month",$firstlyDa)), "<br>";            echo "上月:".date("Y-m-d H:i:s",strtotime("-1 month",$finallyDa)), "<br>";


0 0
原创粉丝点击