<?php
function _getRollingMonths($months = 12) {
$currentTime = strtotime('2015-01-30');
$dates = array();
for($i=$months-1;$i>=0;$i--) {
$dates[] = array(
'year' => date('Y', strtotime("first day of -$i months", $currentTime)),
'month' => date('m', strtotime("first day of -$i months", $currentTime)),
'monthName' => date('M', strtotime("first day of -$i months", $currentTime))
);
}
return $dates;
}
function _getMonths($year = null) {
if (!isset($year)) {
$year = date('Y');
}
$dates = array();
for($month=1;$month<=12;$month++) {
$dates[] = array(
'year' => date('Y', strtotime("$year-$month-01")),
'month' => date('m', strtotime("$year-$month-01")),
'monthName' => date('M', strtotime("$year-$month-01"))
);
}
return $dates;
}
function _getYTDMonths($year = null) {
if (!isset($year)) {
$year = date('Y');
}
$dates = array();
for($i=date('m')-1;$i>=0;$i--) {
$dates[] = array(
'year' => $year,
'month' => date('m', strtotime("first day of -$i months")),
'monthName' => date('M', strtotime("first day of -$i months"))
);
if (date('m', strtotime("-$i months")) == date('m')) {
$dates[count($dates)-1]['day'] = date('d', strtotime("-$i months"));
}
}
return $dates;
}
function debug($var) {
echo "<pre>";
print_r($var);
echo "</pre>";
}
debug(date('Y-m-d H:i:s', strtotime('-1 second', strtotime('+1 month', strtotime('2015-01-01 00:00:00')))));
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- <pre>2015-01-31 23:59:59</pre>
preferences:
235.81 ms | 406 KiB | 352 Q