These are the instructions for 4.0:
System > Site Templates
Cassiopeia Details and Files
New File
from the toolbarhtml/mod_menu
folderFile Name
to exactly this: index-20210203-135009
File Type
to .php
Create
This is a code snippet that showcases the issue:
$format = 'Y-m-d';
$value = '2021-02-03';
$validDate = JFactory::getDate()->createFromFormat($format, $value);
echo $validDate->format('d.m.Y');
File created.
success message and the newly created file being edited in the view.
The code snippet above should show 03.02.2021
Error shows up DateTime::setTimezone(): Argument #1 ($timezone) must be of type DateTimeZone, null given
in both cases.
PHP 8.0.1
The PHP changelog notes this:
Fixed bug #60302 (DateTime::createFromFormat should new static(), not new self()).
Perhaps changing this call https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Date/Date.php#L339-L342
if ($local == false)
{
parent::setTimezone($this->tz);
}
To something like:
if ($local == false && $this->tz !== null)
{
parent::setTimezone($this->tz);
}
Might fix this without causing other issues.
Labels |
Added:
?
|
Labels |
Added:
J4 Issue
?
|
Labels |
Added:
?
|
Yes, but from my understanding it's not meant to set it to UTC - it's meant to temporarily set it to UTC if $local is false and then revert to whatever timezone it was in the first place. Which should be stored in $this->tz
, but I'm not sure why the returned class from createFromFormat()
doesn't have $this->tz
set. It seems that even though it returns a JDate
object, it doesn't call __construct()
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-02-20 19:53:04 |
Closed_By | ⇒ | chmst | |
Labels |
Added:
?
Removed: ? |
Cloing as we have a PR
I resolved this issue with the following on /libraries/src/Date/Date.php line 341