note 109727 added to function.date-diff
| From: | chistyakov dot dmitry at gmail dot com | Date: | Tue, 14 Aug 2012 19:21:06 +0000 |
| Subject: | note 109727 added to function.date-diff | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-190069@lists.php.net to get a copy of this message | ||
Hey guys,
i need to get the difference between 2 dates adjasted in monthes.
<?php
$start_time = strtotime(date('Y-m-01', strtotime('2012-08-14')));
$current_time = strtotime(date('Y-m-01'));
$five_weeks_time = 5 * 7 * 86400;
$monthes = array();
$process_time = $start_time;
while( date('Y-m-01', $process_time) != date('Y-m-01') ){
$process_time = strtotime(date('Y-m-01', $process_time)) + $five_weeks_time;
$monthes[] = date('M', $process_time);
}
?>
array(13) {
[0]=>
string(3) "Aug"
[1]=>
string(3) "Sep"
[2]=>
string(3) "Oct"
[3]=>
string(3) "Nov"
[4]=>
string(3) "Dec"
[5]=>
string(3) "Jan"
[6]=>
string(3) "Feb"
[7]=>
string(3) "Mar"
[8]=>
string(3) "Apr"
[9]=>
string(3) "May"
[10]=>
string(3) "Jun"
[11]=>
string(3) "Jul"
[12]=>
string(3) "Aug"
}
----
Server IP: 195.54.192.44
Probable Submitter: 217.172.19.205
----
Manual Page -- http://www.php.net/manual/en/function.date-diff.php
Edit -- https://master.php.net/note/edit/109727
Del: integrated -- https://master.php.net/note/delete/109727/integrated
Del: useless -- https://master.php.net/note/delete/109727/useless
Del: bad code -- https://master.php.net/note/delete/109727/bad+code
Del: spam -- https://master.php.net/note/delete/109727/spam
Del: non-english -- https://master.php.net/note/delete/109727/non-english
Del: in docs -- https://master.php.net/note/delete/109727/in+docs
Del: other reasons-- https://master.php.net/note/delete/109727
Reject -- https://master.php.net/note/reject/109727
Search -- https://master.php.net/manage/user-notes.php