1

I want to get the lates postDate of a List and format it for the cache tag

{% set latestSubmission = craft.amForms.submissions(
    { formHandle: 'reservation', order: 'dateCreated desc' }).datum('>= '~now).dateCreated().first()
%}

{{ latestSubmission }}

This Returns:

Do., 07 Sep. 2017 10:32:05

But I want to pass it into the Cache Tag so I want to format it and write:

{{ latestSubmission | date('c') }}

This returns the error:

DateTime::__construct(): Failed to parse time string (Do., 07 Sep. 2017 10:32:05) at position 0 (D): The timezone could not be found in the database

Why? Why can’t I reformat it when it is already returning a date?

1

You're getting that error because Do., 07 Sep. 2017 10:32:05 isn't in a valid PHP Date/Time format when you pass it into the |date filter.

Changing it to 07 Sep. 2017 10:32:05 should work.

  • But that means the latestSubmission tag which gets it's data from the am forms plugin saves the date in the wrong formate in the db? since there is no manipulaiton on my side ??? Or ist this a server config thing? – KSPR Sep 11 '17 at 9:08
  • I'd guess it's an plugin issue, but not 100% sure. – Brad Bell Sep 11 '17 at 19:02
  • I'll check back with the plugin dev – KSPR Sep 13 '17 at 12:32
  • c is valid format for the date() function, it outputs in ISO8601 php.net/manual/en/function.date.php – carlcs Dec 6 '17 at 17:40
  • @carlcs oops... my bad! – Brad Bell Dec 7 '17 at 4:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.