Your Ad Here

Posted By

sekihin on 03/25/09


Tagged

php date


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jamesming


get_monthend


 / Published in: PHP
 

  1. /*
  2. 意味:指定した日の月末を取得する
  3. 引数:
  4.   $date 日付を示す文字列(YYYY/MM/DD)を指定します
  5. 返り値:
  6.   指定した日の月末を示す数値
  7. */
  8. function get_monthend($date) {
  9. $dateArr = explode("/", $date);
  10. $year = $dateArr[0];
  11. $month = $dateArr[1];
  12. $lastday = date("d", mktime(0, 0, 0, $month + 1, 0, $year));
  13. return $lastday;
  14. }
  15.  
  16. $date = "2009/02/02";
  17. $monthend = get_monthend($date);
  18.  
  19. echo $monthend;
  20.  
  21. //●実行結果
  22. //28

Report this snippet  

You need to login to post a comment.