设为首页 加入收藏

TOP

php自动获取上一个月的起始时间
2017-10-10 11:57:01 】 浏览:8785
Tags:php 自动 获取 一个月 起始 时间

1、借鉴评论的方法[20170309 edit]

function get_month_start_end($timestamp)
{
    !empty($timestamp) OR $timestamp = time();

    $last_month = date('Y-m-01', $timestamp);
    $last['first'] = strtotime($last_month);
    $last['end'] = strtotime("$last_month +1 month -1 seconds");

    return $last;
}

2、old方法

$last_month = date('Y-m', strtotime('last month'));

$last['first'] = $last_month . '-01 00:00:00';
$last['end'] = date(‘Y-m-d H:i:s’, strtotime("$last_month +1 month -1 day +23 hours +59 minutes +59 seconds"));

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇PHP中面相对象对象的知识点整理 下一篇说说APP接口中的版本控制

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目