Skip to content

Instantly share code, notes, and snippets.

@zaru
Created August 1, 2012 08:52
Show Gist options
  • Save zaru/3225150 to your computer and use it in GitHub Desktop.
Save zaru/3225150 to your computer and use it in GitHub Desktop.
日付の差を計算する
<?php
//日付の差を月単位で計算する(PHP>=5.3)
$date1 = new DateTime('2012-08-01');
$date2 = new DateTime('2013-02-24');
$interval = $date1->diff($date2);
$diffMonth = $interval->y * 12 + $interval->m;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment