public static function date($time, $format = NULL)
{
if ($time == NULL) {
// intentionally ==
return NULL;
}
if (!isset($format)) {
$format = self::$dateFormat;
}
if ($time instanceof \DateInterval) {
return $time->format($format);
} elseif (is_numeric($time)) {
$time = new \DateTime('@' . $time);
$time->setTimeZone(new \DateTimeZone(date_default_timezone_get()));
} elseif (!$time instanceof \DateTime && !$time instanceof \DateTimeInterface) {
$time = new \DateTime($time);
}
return strpos($format, '%') === FALSE ? $time->format($format) : strftime($format, $time->format('U'));
// formats according to locales
}