I am trying to display custom date fields the normal way and instead I'm getting the UNIX format of the dates.
Link to a page where the issue can be seen: hidden link
I expected to see (underneath the Bent Spun graphic):
The tunes that rocked the hebdomad for the tracking period beginning July 16, 2018 and ending July 22, 2018.
Instead, I got:
The tunes that rocked the hebdomad for the tracking period beginning 1531699200 and ending 1532217600.
Here is the code I am using to display the date fields mentioned above.
div><i>The tunes that rocked the hebdomad for the tracking period beginning <?php echo types_render_field("tracking-period-begin-date", array(output=>"normal")); ?> and ending <?php echo types_render_field("tracking-period-end-date", array(output=>"normal")); ?>.</i><p> </p></div>
Hi, try these options in the arguments array instead:
echo types_render_field("tracking-period-begin-date", array("style"=>"text", "format"=>"F d, Y" ));
...
echo types_render_field("tracking-period-end-date", array("style"=>"text", "format"=>"F d, Y" ));
"output"=>"normal" is the default, so there's no need to include that. "format" is how you define the date format to apply to the timestamp. "F d, Y" will produce the format "July 24, 2018". Without the "style"=>"text" option, the timestamp will be displayed with no formatting.
https://toolset.com/documentation/customizing-sites-using-php/functions/#date
Let me know if the problem is not fully resolved and I can offer more assistance.
Thanks Christian! Your solution worked! It's weird that the old code used to work, and then after I updated my Toolset today, it stopped working and started showing the unformatted UNIX dates instead. I guess something was changed in the Toolset code. Thanks again!
Okay thanks for the update. It seems that a change was introduced that caused existing shortcodes to behave differently in the new versions. We have a ticket in place with our developers to fix the backwards-compatibility issue here, but for now the best solution is to use the style and format attributes I described.
Our developers have just confirmed this issue will be fixed in the next release, so existing date shortcodes will continue to function as expected. I'll let you know when that release is available.
Quick update to let you know a patch has been created. Feel free to install the patch here, or wait until the next plugin release. https://toolset.com/errata/types-fields-are-not-displayed-properly-using-types_render_field/
Thanks very much Christian!