PHP日期操作

WBOY
發布: 2016-07-29 09:13:59
原創
793 人瀏覽過
  //返回指定月份的第一天

  function get_the_month_first_day_str($theyear, $themonth) {

    return date("Y-m-d", mktime(0, 0, 0, $themonth, 1, $theyear));

  }

  

  //返回指定月份的最后一天

  function get_the_month_last_day_str($theyear, $themonth) {

    $theday = date("t", mktime(0, 0, 0, $themonth, 1, $theyear));

    return date("Y-m-d", mktime(0, 0, 0, $themonth, $theday, $theyear));

  }

  

  //返回指定日期所在周的第一天(周日为第一天,周一为第二天,以此类推)

  function get_the_week_first_day_str($theyear, $themonth, $theday) {

  	$date = mktime(0, 0, 0, $themonth, $theday, $theyear);

  	$date = $date - (24 * 60 * 60 * date("w", $date));

  	return date("Y-m-d", $date);

  }

  

  //返回指定日期所在周的最后一天(周日为第一天,周一为第二天,以此类推)

  function get_the_week_last_day_str($theyear, $themonth, $theday) {

  	$date = mktime(0, 0, 0, $themonth, $theday, $theyear);

  	$date = $date - (24 * 60 * 60 * date("w", $date)) + (24 * 60 * 60 * 6);

  	return date("Y-m-d", $date);

  }
登入後複製

版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。

以上就介紹了PHP日期操作,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!