• Resolved netschmiede24

    (@netschmiede24)


    Hi, I have a date field (called “beginn”) in my output and the standard output is d.m.Y, which works well.

    However in some part of the website I want to output ONLY the year (Y) – and I found this explanation: https://docs.pods.io/displaying-pods/magic-tags/display-filters-with-magic-tags/

    So I added the following function in a snippet:

    function datumjahr($date) {
    return mysql2date('Y', $date);
    }

    But when I try to output the year in the template via {@beginn,datumjahr} , the output is of the format Y-m-d.

    What am I doing wrong?

    Thanks,

    Astrid

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support pdclark

    (@pdclark)

    <?php
    function datumjahr( $date_as_text ) {
    	return date( 'Y', strtotime( $date_as_text ) );
    }
    Thread Starter netschmiede24

    (@netschmiede24)

    Sorry, I still get Y-m-d as my output.

    The snippet function is exactly what you said.

    In my template I call {@beginn,datumjahr}

    What else can be wrong?

    Plugin Support pdclark

    (@pdclark)

    The reason for the formatting callback not running is likely the new security setting added to Pods Admin > Settings. In default setup, there is a field near the end of the page called Display callbacks allowed

    If the formatting function is called datumjahr, an appropriate value for this field might be esc_attr,esc_html,datumjahr — which would allow the date format callback and the two default attribute and HTML escaping functions to be used as Magic Tag helpers.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Different output of date’ is closed to new replies.