| @@ -1,0 +1,40 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +defined('ABSPATH') || die('Restricted Access'); | |
| 4 | + | |
| 5 | +function acym_getTimeOffsetCMS(): int | |
| 6 | +{ | |
| 7 | + static $timeoffset = null; | |
| 8 | + if ($timeoffset === null) { | |
| 9 | + //We replace the . with : WordPress give format like UTC+5.45, but we want something like UTC+5:45 | |
| 10 | + $timeoffset = str_replace('.', ':', acym_getCMSConfig('offset')); | |
| 11 | + | |
| 12 | + if (!is_numeric($timeoffset)) { | |
| 13 | + $timezone = new DateTimeZone($timeoffset); | |
| 14 | + $timeoffset = $timezone->getOffset(new DateTime()); | |
| 15 | + } | |
| 16 | + } | |
| 17 | + | |
| 18 | + return $timeoffset; | |
| 19 | +} | |
| 20 | + | |
| 21 | +function acym_dateTimeCMS(int $time) | |
| 22 | +{ | |
| 23 | + return gmdate('Y-m-d H:i:s', $time); | |
| 24 | +} | |
| 25 | + | |
| 26 | +function acym_getDateTimeFormat(string $default = ''): string | |
| 27 | +{ | |
| 28 | + $noTimeDate = [ | |
| 29 | + 'ACYM_DATE_FORMAT_LC1', | |
| 30 | + 'ACYM_DATE_FORMAT_LC3', | |
| 31 | + 'ACYM_DATE_FORMAT_LC4', | |
| 32 | + 'ACYM_DATE_FORMAT_LC5', | |
| 33 | + ]; | |
| 34 | + | |
| 35 | + $dateFormat = get_option('date_format', 'Y-m-d'); | |
| 36 | + | |
| 37 | + $timeFormat = in_array($default, $noTimeDate) ? '' : ' '.get_option('time_format', 'H:i'); | |
| 38 | + | |
| 39 | + return $dateFormat.$timeFormat; | |
| 40 | +} | |