54 $monthDays = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
55 $d = $monthDays[$m - 1];
56 if ($m == 2 && ($y % 4) == 0 && ($y % 100) != 0) $d++;
70 $weekDaysInMonth = array
72 28 => array(20, 20, 20, 20, 20, 20, 20),
73 29 => array(21, 21, 21, 21, 21, 20, 20),
74 30 => array(22, 22, 22, 22, 21, 20, 21),
75 31 => array(23, 23, 23, 22, 21, 21, 22)
79 $date = strtotime(
"$year-$month-01");
81 $first = date(
"N", $date) - 1;
82 return $weekDaysInMonth[$days][$first];
96 $yyyy = substr($start,0,4);
97 $yyyy_2 = substr($end,0,4);
98 $mm = substr($start,5,2);
99 $mm_2 = substr($end,5,2);
100 $dd = substr($start,8,2);
101 $dd_2 = substr($end,8,2);
103 if($yyyy != $yyyy_2 || $mm != $mm_2 || $dd != $dd_2)
109 $hh = substr($start,11,2);
110 $mi = substr($start,14,2);
111 $hh_2 = substr($end,11,2);
112 $mi_2 = substr($end,14,2);
113 $s_time = date(
"g:ia", mktime($hh,$mi));
114 $e_time = date(
"g:ia", mktime($hh_2,$mi_2));
129 $modifier = $months.
' months';
130 $back_modifier = -$months.
' months';
132 $date->modify($modifier);
133 $back_to_init = clone $date;
134 $back_to_init->modify($back_modifier);
136 while($init->format(
'm') != $back_to_init->format(
'm'))
138 $date->modify(
'-1 day');
139 $back_to_init = clone $date;
140 $back_to_init->modify($back_modifier);
154 $modifier = $years.
' years';
155 $date->modify($modifier);
157 while($date->format(
'm')!=$init->format(
'm'))
159 $date->modify(
'-1 day');
170 $time = strtotime($date);
176 $s = ($when == 1)?
"second":
"seconds";
177 return "$when $s ago";
179 else if ($ago < 3600)
181 $when = round($ago / 60);
182 $m = ($when == 1)?
"minute":
"minutes";
183 return "$when $m ago";
185 else if ($ago >= 3600 && $ago < 86400)
187 $when = round($ago / 60 / 60);
188 $h = ($when == 1)?
"hour":
"hours";
189 return "$when $h ago";
191 else if ($ago >= 86400 && $ago < 2629743.83)
193 $when = round($ago / 60 / 60 / 24);
194 $d = ($when == 1)?
"day":
"days";
195 return "$when $d ago";
197 else if ($ago >= 2629743.83 && $ago < 31556926)
199 $when = round($ago / 60 / 60 / 24 / 30.4375);
200 $m = ($when == 1)?
"month":
"months";
201 return "$when $m ago";
205 $when = round($ago / 60 / 60 / 24 / 365);
206 $y = ($when == 1)?
"year":
"years";
207 return "$when $y ago";
219 for($i = 1; $i < 13; ++$i)
221 $months[$i] = date(
"F", mktime(0, 0, 0, $i, 10));
DateUtils - provides support for date/time manipulation.
static getMonthWeekDays($month, $year)
Get the number of week days in the specified month.
static formatStartDateToEndDate($start, $end)
static fuzzyDate($date)
Fuzzy approximates of some time in the past.
static addMonths(&$date, $months)
DateTime will fail to increment month correctly when current date is last day of 31 day month.
static getMonthDays($m, $y)
Returns the number of days in the specified month.
static getMonths()
Return an array of month names in the currently selected locale, indexed by month number.
static addYears(&$date, $years)
DateTime will fail to increment year correctly in some instances.
formatDateShort($date)
Utility function to format date in short form (MM/DD/YYYY), with no time component.
formatDateTime12Hr($datetime)