Merge pull request #15850 from civicrm/5.20
[civicrm-core.git] / CRM / Core / Smarty / plugins / modifier.crmDate.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 * $Id$
17 *
18 */
19
20 /**
21 * Convert the date string "YYYY-MM-DD" to "MM<long> DD, YYYY".
22 *
23 * @param string $dateString
24 * Date which needs to converted to human readable format.
25 *
26 * @param null $dateFormat
27 * @param bool $onlyTime
28 *
29 * @return string
30 * human readable date format | invalid date message
31 */
32 function smarty_modifier_crmDate($dateString, $dateFormat = NULL, $onlyTime = FALSE) {
33 if ($dateString) {
34 // this check needs to be type sensitive
35 // CRM-3689, CRM-2441
36 if ($dateFormat === 0) {
37 $dateFormat = NULL;
38 }
39 if ($onlyTime) {
40 $config = CRM_Core_Config::singleton();
41 $dateFormat = $config->dateformatTime;
42 }
43
44 return CRM_Utils_Date::customFormat($dateString, $dateFormat);
45 }
46 return '';
47 }