switch ($dataType) {
case 'Date':
- $customTimeFormat = '';
$customFormat = NULL;
- switch ($timeFormat) {
- case 1:
- $customTimeFormat = '%l:%M %P';
- break;
-
- case 2:
- $customTimeFormat = '%H:%M';
- break;
-
- default:
- // if time is not selected remove time from value
- $value = substr($value, 0, 10);
- }
-
- $supportableFormats = array(
- 'mm/dd' => "%B %E%f $customTimeFormat",
- 'dd-mm' => "%E%f %B $customTimeFormat",
- 'yy' => "%Y $customTimeFormat",
- 'M yy' => "%b %Y $customTimeFormat",
- 'yy-mm' => "%Y-%m $customTimeFormat",
- );
+ $actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats();
if ($format = CRM_Utils_Array::value('date_format', $field)) {
- if (array_key_exists($format, $supportableFormats)) {
- $customFormat = $supportableFormats["$format"];
+ if (array_key_exists($format, $actualPHPFormats)) {
+ $customTimeFormat = (array)CRM_Utils_Array::value($format, $actualPHPFormats);
+ switch ($timeFormat) {
+ case 1:
+ $customTimeFormat[] = 'g:iA';
+ break;
+
+ case 2:
+ $customTimeFormat[] = 'G:i';
+ break;
+
+ default:
+ // if time is not selected remove time from value
+ $value = substr($value, 0, 10);
+ }
+ $customFormat = implode(" ", $customTimeFormat);
}
}
-
- $retValue = CRM_Utils_Date::customFormat($value, $customFormat);
+ $retValue = CRM_Utils_Date::processDate($value, NULL, FALSE, $customFormat);
break;
case 'Boolean':
CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities);
if ($returnValues['data_type'] == 'Date') {
$dateFields[$fieldIDs[$key]] = 1;
+ $actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats();
+ $dateFormat = (array) CRM_Utils_Array::value($returnValues['date_format'], $actualPHPFormats);
+ $timeFormat = CRM_Utils_Array::value('time_format', $returnValues);
}
$optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]);
if (!empty($dateFields) && array_key_exists($fieldId, $dateFields)) {
// formated date capture value capture
$dateFieldsVals[$fieldId][$recId] = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options);
+
+ //set date and time format
+ switch ($timeFormat) {
+ case 1:
+ $dateFormat[] = 'g:iA';
+ break;
+
+ case 2:
+ $dateFormat[] = 'G:i';
+ break;
+
+ default:
+ // if time is not selected remove time from value
+ $result[$recId][$fieldId] = substr($result[$recId][$fieldId], 0, 10);
+ }
+ $result[$recId][$fieldId] = CRM_Utils_Date::processDate($result[$recId][$fieldId], NULL, FALSE, implode(" ", $dateFormat));
}
else {
// assign to $result
{foreach from=$records key=recId item=rows}
<tr class="{cycle values="odd-row,even-row"}">
{foreach from=$headers key=hrecId item=head}
- {if $dateFieldsVals.$hrecId.$recId}
- <td {crmAttributes a=$attributes.$hrecId.$recId}>{$rows.$hrecId|crmDate:"%b %d, %Y %l:%M %P"}</td>
- {else}
- <td {crmAttributes a=$attributes.$hrecId.$recId}>{$rows.$hrecId}</td>
- {/if}
+ <td {crmAttributes a=$attributes.$hrecId.$recId}>{$rows.$hrecId}</td>
{/foreach}
<td>{$rows.action}</td>
{foreach from=$dateFieldsVals key=fid item=rec}