}
}
-
/**
* @param null $timeStamp
*
* @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');
}
foreach ([
- 'from',
- 'to',
- ] as $item) {
+ 'from',
+ 'to',
+ ] as $item) {
if (!empty($$item)) {
$dateRange[$item] = self::format($$item);
}
return $field;
}
-
/**
* Get the fields required for the 'extra' parameter when adding a datepicker.
*
return $month;
}
-
/**
* Convert a relative date format to an api field.
*
}
}
+ /**
+ * 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);
+ }
+
}