本文整理匯總了PHP中CRM_Utils_Date::getFromTo方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Utils_Date::getFromTo方法的具體用法?PHP CRM_Utils_Date::getFromTo怎麽用?PHP CRM_Utils_Date::getFromTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Utils_Date
的用法示例。
在下文中一共展示了CRM_Utils_Date::getFromTo方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: fixDateValues
static function fixDateValues($relative, &$from, &$to)
{
if ($relative) {
list($from, $to) = CRM_Utils_Date::getFromTo($relative, $from, $to);
}
}
示例2: convertCustomDateRelativeFields
/**
* Convert submitted values for relative custom date fields to query object format.
*
* The query will support the sqlOperator format so convert to that format.
*
* @param array $formValues
* Submitted values.
* @param array $params
* Converted parameters for the query object.
* @param string $values
* Submitted value.
* @param string $fieldName
* Submitted field name. (Matches form field not DB field.)
*/
protected static function convertCustomDateRelativeFields(&$formValues, &$params, $values, $fieldName)
{
if (empty($values)) {
// e.g we might have relative set & from & to empty. The form flow is a bit funky &
// this function gets called again after they fields have been converted which can get ugly.
return;
}
$customFieldName = self::getCustomFieldName($fieldName);
if (substr($fieldName, -9, 9) == '_relative') {
list($from, $to) = CRM_Utils_Date::getFromTo($values, NULL, NULL);
} else {
if ($fieldName == $customFieldName . '_to' && CRM_Utils_Array::value($customFieldName . '_from', $formValues)) {
// Both to & from are set. We only need to acton one, choosing from.
return;
}
list($from, $to) = CRM_Utils_Date::getFromTo(NULL, empty($formValues[$customFieldName . '_from']) ? NULL : $formValues[$customFieldName . '_from'], CRM_Utils_Array::value($customFieldName . '_to', $formValues));
}
if ($from) {
if ($to) {
$relativeFunction = array('BETWEEN' => array($from, $to));
} else {
$relativeFunction = array('>=' => $from);
}
} else {
$relativeFunction = array('<=' => $to);
}
$params[] = array($customFieldName, '=', $relativeFunction, 0, 0);
}