• Resolved nick5638

    (@nick5638)


    I’m basically having the same problem as @berttervoert had about 2 years ago (I think), with the one difference being I don’t know how to solve it.

    I have a date field setup on one of my pods, I have a website running in Dutch and using Elementor page-builder. When I try to display a pods date-field through Elementor (using dynamic linking) I get the date in English display instead of the Dutch one. The website is set-up in Dutch and the back-end is also configured in Dutch. In fact, the back-end displays the Dutch value.

    It might be entirely my fault, as I’m not too well versed in this system (yet), but I could really use some help. Thanks in advance!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support pdclark

    (@pdclark)

    Page builders will frequently use their own display functions.

    The WordPress core display function for an internationalized date is date_i18n( $format, $timestamp_with_offset, $gmt ) where the format is a string of PHP date formats, the timestamp is a Unix timestamp shifted for the appropriate timezone, and gmt is a boolean defaulting to false as to whether the timezone is gmt.

    Pods stores raw date/time values as a string in a format like YYYY-MM-DD HH:MM:SS

    The PHP function to convert a string/text date to a unix timestamp is strtotime

    One fast way to get custom displays into Elementor is by adding a shortcode, such as [date_i18n], if the date field is called name_of_date_field :

    <?php
    /**
    * Plugin Name: International Date Shortcode
    * Description: <code>[date_i18n]</code>
    */
    add_shortcode(
    'date_i18n',
    function( $atts, $content, $tag ) {
    $date_value = get_post_meta( get_the_ID(), 'name_of_date_field', true );
    if ( empty( $date_value ) ) {
    return '';
    }
    return date_i18n(
    // Date format set in WP Admin settings
    get_option( 'date_format' ),
    strtotime( $date_value )
    );
    }
    );
Viewing 1 replies (of 1 total)

The topic ‘Wrong Local on Frontend’ is closed to new replies.