PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
    您现在的位置: 首页 > 开发编程 > PHP教程 > 正文

    php strtotime函数的使用方法

    作者:admin来源:原创浏览:时间:2020-09-30 00:07:50我要评论
    导读:strtotime() 函数灵活的运用它,会给你的工作带来不少方便,最近由于项目要求做一个统计功能,统计当前日期之前的前30天的记录。功能挺简单,下面将本次实现的方法和大家分享一下,方便有
    strtotime() 函数将任何英文文本的日期时间描述解析为 Unix 时间戳。
    其实主要就是用到了php的strtotime这个函数,strtotime('n day'),示例如下:
    $days=array();
    for($i=0;$i<=7;$i++){//这里数字根据需要变动
    	$days[]=date("Y-m-d",strtotime('-'.$i.'day'));
    }//http://www.bcty365.com
    echo '<pre>';print_r($days);
    

    结果将显示如下:

    Array
    (
        [0] => 2014-03-21
        [1] => 2014-03-20
        [2] => 2014-03-19
        [3] => 2014-03-18
        [4] => 2014-03-17
        [5] => 2014-03-16
        [6] => 2014-03-15
        [7] => 2014-03-14
    )



    转载请注明(B5教程网)原文链接:https://b5.mxunkeji.com/content-10-51-1.html
    相关热词搜索: strtotime php