• 河南网站建设-郑州网站设计-郑州网站建设-手机建站-郑州建站-上海建站

  • 专注网站建设 服务热线: 13061801310

当前位置:好东东网 > 近期动态 > 技术分享 > 正文

php 获取上个月此刻的时间代码

发布时间:2017-06-02 | 发布者: 东东工作室 | 浏览次数:
经过再三的搜索和敲打代码,终于实现了上个月此刻的时间,输出的代码如:2017-06.01  14:10:50
function last_month_today($time){
    $last_month_time = mktime(date("G", $time), date("i", $time),
                date("s", $time), date("n", $time), 0, date("Y", $time));
    $last_month_t =  date("t", $last_month_time);
    if ($last_month_t < date("j", $time)) {
        return date("Y-m-t H:i:s", $last_month_time);
    }
    return date(date("Y-m", $last_month_time) . "-d". " H:i:s", $time);
}
$time=time();
echo last_month_today($time);
完美时间的上个月此刻的时间

转载请标注:东东工作室——php 获取上个月此刻的时间代码