最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PHP簡單獲取上月、本月、近15天、近30天的方法示例

 更新時間:2017年07月03日 12:02:30   作者:molaifeng  
這篇文章主要介紹了PHP簡單獲取上月、本月、近15天、近30天的方法,結(jié)合實例形式分析了PHP通過自定義函數(shù)封裝的日期與時間戳轉(zhuǎn)換相關(guān)運算技巧,需要的朋友可以參考下

本文實例講述了PHP簡單獲取上月、本月、近15天、近30天方法。分享給大家供大家參考,具體如下:

/**
 * 獲取統(tǒng)計時間
 * @param $type
 * 1 上月
 * 2 本月
 * 3 近15天
 * 4 近30天
 * @return array
 */
function getDateInfo($type)
{
  $data = array(
    array(
      'firstday' => date('Ym01', strtotime('-1 month')),
      'lastday' => date('Ymt', strtotime('-1 month')),
    ),
    array(
      'firstday' => date('Ym01', strtotime(date("Y-m-d"))),
      'lastday' => date('Ymd', strtotime((date('Ym01', strtotime(date("Y-m-d")))) . " +1 month -1 day")),
    ),
    array(
      'firstday' => date('Ymd', strtotime("-15 day")),
      'lastday' => date('Ymd', strtotime('-1 day')),
    ),
    array(
      'firstday' => date('Ymd', strtotime("-30 day")),
      'lastday' => date('Ymd', strtotime('-1 day')),
    ),
  );
  return is_null($type) ? $data : $data[$type-1];
}
print_r(getDateInfo(1));//獲取上個月第一天與最后一天

運行結(jié)果:

Array
(
  [firstday] => 20170601
  [lastday] => 20170630
)

PS:這里再為大家推薦幾款時間及日期相關(guān)工具供大家參考使用:

在線日期/天數(shù)計算器:
http://tools.jb51.net/jisuanqi/date_jisuanqi

在線日期計算器/相差天數(shù)計算器:
http://tools.jb51.net/jisuanqi/datecalc

在線日期天數(shù)差計算器:
http://tools.jb51.net/jisuanqi/onlinedatejsq

Unix時間戳(timestamp)轉(zhuǎn)換工具:
http://tools.jb51.net/code/unixtime

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php日期與時間用法總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP基本語法入門教程》、《php面向?qū)ο蟪绦蛟O(shè)計入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對大家PHP程序設(shè)計有所幫助。

相關(guān)文章

最新評論

灵石县| 囊谦县| 革吉县| 明光市| 尼木县| 雷波县| 荔波县| 龙川县| 濮阳市| 曲水县| 北流市| 班玛县| 绵竹市| 云南省| 子洲县| 贡山| 洛南县| 井研县| 招远市| 乌拉特后旗| 湖口县| 柘荣县| 潞城市| 凯里市| 汤原县| 同德县| 项城市| 大同县| 三门峡市| 辽宁省| 文昌市| 页游| 区。| 郯城县| 中西区| 当涂县| 安乡县| 新竹县| 高碑店市| 确山县| 桂东县|