Skip Navigation

[Gelöst] Formatted dates not displaying correctly in PHP templates

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem: Dates are being displayed as timestamps instead of formatted dates when using types_render_field.

Solution: Update to Types 3.0.7

This support ticket is created vor 6 Jahren, 3 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Dieses Thema enthält 5 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von guyA-2 vor 6 Jahren, 3 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#1069298
Screen Shot 2018-07-31 at 15.16.05.png

I am trying to: Get a start-date and end-date field to display correctly in a PHP template.

This was working and I was using:
<?php echo (types_render_field( 'start-date', array() ));?> - <?php echo (types_render_field( 'end-date', array() ));?> where start-date is the name of the start date custom field and end-date was the custom field for end date custom field.

I have no idea why this would suddenly change.

I checked out this post on the support forum:
https://toolset.com/forums/topic/displaying-date-field-information-in-php-template-file/

and see that the code was slightly different so I tweaked my code to:
<?php echo types_render_field( 'start-date', array('format'=>"M d") );?> - <?php echo types_render_field( 'end-date', array('format'=>"M d") );?></p>

But it still doesn't work. You can see this specifically on the archive-workshops.php file on line 16.

The site is password protected so if you open a private message I can give you access.

In the meantime see my attached screengrab - the dates should appear in the green strip with the calendar icon.

Thanks for your support!

#1069440

Hi, there's currently a known issue with types_render_field and formatted dates:
https://toolset.com/errata/types-fields-are-not-displayed-properly-using-types_render_field/

As a temporary fix, you can add 'style'=>'text' to the arguments array, or you can apply the patch mentioned in the post above.

#1069511

Thanks for your quick response Christian.
FYI we have 4 sites currently in development that all use this functionality so we're reluctant to start patching with temporary fixes if you have a new release coming out with a fix.

Can you confirm this will be fixed in the next release and when the next release is due?

Thanks,

Guy

#1069540

I can't confirm the release or release date with certainty yet, but the fix is currently being tested in QA. Right now it looks likely it will be included in the next release, but I can't guarantee that or a timeline for delivery.

#1078793

This issue has been resolved in Types 3.0.7, which is now available for download or automatic update.

#1079448

Thanks for letting us know Christian.
We've now updated across all our sites now and confirm the fix is working!