Your Ad Here

Posted By

sekihin on 04/28/09


Tagged

php date


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Dean_IconWeb
fackz
BrianCoyDesign


get next month


 / Published in: PHP
 

  1. /*
  2. 意味:指定した日の来月を取得する
  3. 引数:
  4.   $date 日付を示す文字列(YYYY/MM/DD)を指定します
  5. 返り値:
  6.   指定した日の来月を示す数値
  7. */
  8. function get_next_month($date) {
  9. $date = str_replace("/", "-", $date);
  10. $year=date("Y",strtotime($date));
  11. $month=date("n",strtotime($date)) + 1;
  12. if ($month == 13) {
  13. $month = 1;
  14. $year = $year + 1;
  15. }
  16. $day = date("t", mktime(0, 0, 0, $month, 1, $year));
  17. return date("Y/m/d", mktime(0, 0, 0, $month, $day, $year));
  18. }

Report this snippet  

You need to login to post a comment.