$endDate = strtotime((null === $endDate) ? 'now' : $endDate);
$startDate = strtotime($startDate);
$age = 0;
while ($endDate > $startDate = strtotime('+1 year', $startDate)) {
++$age;
}
return $age;
Get the timestamp for the last day of a month (PHP)
mktime(null, null, null, $month, date('t', mktime(null, null, null, $month, 1, $year)), $year)
Get the timestamp for the first day (monday) of a week number
// Offset: numeric weekday of January,
// 1st in given year (e.g. 'Donnerstag' => 4)
$offset = date('w', mktime(0, 0, 0, 1, 1, $weekNumber);
// Calculate timestamp of monday from above offset
$offset = ($offset < 5) ? 1-$offset : 8-$offset;
$monday = mktime(0, 0, 0, 1 , 1+$offset, $weekNumber);
// Finally: calculate timestamp of monday in requested week
return strtotime('+' . ($dateArray[1] - 1) . 'weeks',
$monday);
Java: Datum/Datum-Format Thread-Safe
FastDateFormat is a fast and thread-safe version of SimpleDateFormat.
