In 5.8 all my custom date attribute values are "01.01.1970"

Permalink
Since I updated my site to 5.8 all my custom date attributes values are changed to and displayed as "01.01.1970". And I also cannot leave the attributes empty like before the update. Changes are ignored after saving.

In 5.7 everything worked fine with:
$date = Loader::helper('date');

and
setlocale(LC_TIME, "de_DE.utf8");

and
<?php echo strftime(" %d.%m.%Y",strtotime($c->getAttribute('ernennung')));


Different to that “CollectionDatePublic" works fine and its changes are saved
<?php echo strftime(" %d.%m.%Y",strtotime($c->getCollectionDatePublic()));?>

Is it about the database or do I have to change some code in the core files?
Thanks in advance.
Mathias

MathiasB
 
ob7dev replied on at Permalink Reply
ob7dev
I'm not sure if this will help, but Loader is deprecated in favor of:
$date = Core::make('helper/date');
... I believe...
MathiasB replied on at Permalink Reply
MathiasB
Nope... :-(
But thank you very much...
JohntheFish replied on at Permalink Reply
JohntheFish
1.1.1970 is time zero, and the rest works with $c->getCollectionDatePublic(), so $c->getAttribute('ernennung') must be returning 0 or null.
MathiasB replied on at Permalink Reply
MathiasB
Ok, but how to display a custom date in C5.8?
ob7dev replied on at Permalink Reply
ob7dev
Here: https://documentation.concrete5.org/api/class-Concrete.Core.Localiza...

And here: http://php.net/manual/en/function.date.php...

So
$dh = Core::make('helper/date');
$dateTimeObject = $c->getAttribute("my_date_attribute");
$customDate = $dh->formatCustom("M Y D", $dateTimeObject); 
echo $customDate;
"M Y D" is where you can supply your own custom PHP date format.
MathiasB replied on at Permalink Reply
MathiasB
Ok thank you,
but 1. I cannot write that code for every single custom date. I got several dates (beginning of membership (mgl_dat), day of birth (geb), day of death (verst), days of distinction (ernennung) etc.) and
2. C5 doesn't display the dates in the form

Best Mathias
MathiasB replied on at Permalink Reply
MathiasB
Hello again,
now I installed a brand new 5.8 version. I made a attribute (date) and filled the form. After saving the php displays 1.1.1970 and when I open up the edit form the field "date" is empty again.
Sorry, but this must be a bug.

I'll try 5.7 again to proof that.

Best Mathias
JohntheFish replied on at Permalink Reply
JohntheFish
Please report bugs on the bug tracker at
http://www.concrete5.org/developers/bugs/8-1-0/...

(The core team don't browse the forums looking for reports such as yours, so this will go un-noticed unless you post it on the bug tracker)
MathiasB replied on at Permalink Reply
MathiasB
Ok, thank you. I'll do that.
This would be my second bug-report. I even won a badge :-)

I just installed a new C5.7 and everything works fine. I guess I will make the new site with C5.7.

Best Mathias
JohntheFish replied on at Permalink Reply
JohntheFish
There were changes to the infrastructure for attributes from 5.7 to v8 to facilitate Express, though the new system is supposed to be backward compatible.