Skip to content

Commit 26c9f50

Browse files
authored
CalendarField: changing strftime to date (joomla#44114)
1 parent cb0c4c8 commit 26c9f50

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

libraries/src/Form/Field/CalendarField.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Joomla\CMS\Factory;
1313
use Joomla\CMS\Form\FormField;
14+
use Joomla\CMS\HTML\HTMLHelper;
1415
use Joomla\CMS\Language\Text;
1516
use Joomla\Registry\Registry;
1617

@@ -320,7 +321,7 @@ protected function getInput()
320321
$date = \DateTimeImmutable::createFromFormat('U', strtotime($value));
321322
$value = $date->format($this->filterFormat);
322323
} else {
323-
$value = strftime($this->format, strtotime($value));
324+
$value = date(HTMLHelper::strftimeFormatToDateFormat($this->format), strtotime($value));
324325
}
325326

326327
date_default_timezone_set($tz);

libraries/src/HTML/HTMLHelper.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,18 @@ public static function strftimeFormatToDateFormat(string $strftimeformat)
12711271
'%H',
12721272
'%M',
12731273
'%S',
1274+
'%a',
1275+
'%A',
1276+
'%e',
1277+
'%j',
1278+
'%u',
1279+
'%w',
1280+
'%W',
1281+
'%b',
1282+
'%B',
1283+
'%h',
1284+
'%g',
1285+
'%I',
12741286
],
12751287
[
12761288
'Y',
@@ -1279,6 +1291,18 @@ public static function strftimeFormatToDateFormat(string $strftimeformat)
12791291
'H',
12801292
'i',
12811293
's',
1294+
'D',
1295+
'l',
1296+
'j',
1297+
'z',
1298+
'N',
1299+
'w',
1300+
'W',
1301+
'M',
1302+
'F',
1303+
'M',
1304+
'y',
1305+
'h',
12821306
],
12831307
$strftimeformat
12841308
);

0 commit comments

Comments
 (0)