X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FDate.php;h=fa96fca47fa1a0394a2bd4cd7b6c781a3101d498;hb=842c077aa1e9f89dd9a4af1bf099ba5e5d7f7b4d;hp=913c930a4559b67c7b8d0ce3cb2c8b5876b25419;hpb=01f7363f74d44b4ff35161c02d7975b7993a2863;p=civicrm-core.git diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index 913c930a45..fa96fca47f 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -763,7 +763,6 @@ class CRM_Utils_Date { } } - /** * @param null $timeStamp * @@ -901,7 +900,7 @@ class CRM_Utils_Date { * @return int * array $results contains years or months */ - static public function calculateAge($birthDate) { + public static function calculateAge($birthDate) { $results = []; $formatedBirthDate = CRM_Utils_Date::customFormat($birthDate, '%Y-%m-%d'); @@ -1858,9 +1857,9 @@ class CRM_Utils_Date { } foreach ([ - 'from', - 'to', - ] as $item) { + 'from', + 'to', + ] as $item) { if (!empty($$item)) { $dateRange[$item] = self::format($$item); } @@ -1961,7 +1960,6 @@ class CRM_Utils_Date { return $field; } - /** * Get the fields required for the 'extra' parameter when adding a datepicker. * @@ -2170,7 +2168,6 @@ class CRM_Utils_Date { return $month; } - /** * Convert a relative date format to an api field. * @@ -2207,4 +2204,17 @@ class CRM_Utils_Date { } } + /** + * Print out a date object in specified format in local timezone + * + * @param DateTimeObject $dateObject + * @param string $format + * @return string + */ + public static function convertDateToLocalTime($dateObject, $format = 'YmdHis') { + $systemTimeZone = new DateTimeZone(CRM_Core_Config::singleton()->userSystem->getTimeZoneString()); + $dateObject->setTimezone($systemTimeZone); + return $dateObject->format($format); + } + }