• Resolved stevejones031

    (@stevejones031)


    I have created a layout using a custom field with the time input selected. I’ve updated the format to be 00:00PM as well as the default WordPress format to be the same. When I pull the time it displays like this: 00:00:00, with the addition of the seconds.

    The page is being built using Elementor Dymanic Tags.

    I tested the default post meta section from Elementor alongside and this pulls correctly as 00:00PM, so it seems Elementor is not the issue.

    I also logged this with Elementor, as suggested in a previous thread, but they said I should chat to Pods as this is where the time data is coming from.

    Any ideas?

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Paul Clark

    (@pdclark)

    There are many ways to output time formats from post meta in WordPress.

    While Pods does store seconds in the raw date/time data, it would still be up to Elementor to format the time according to site settings or field settings if Elementor Dynamic Tags is being used as the output method.

    The fastest way to work around this is to register your own shortcode for use in Elementor to output the time field in your desired format. See WordPress Shortcode API and PHP DateTime Formats.

    For example, if the name of your field is event_start_time, the following code would register a shortcode [start_time] which will output the time as 1:23 PM.

    <?php
    
    add_shortcode(
    	'start_time',
    	function( $atts, $content, $tagname ) {
    		return date(
    			'g:i A',
    			strtotime(
    				get_post_meta(
    					get_the_ID(),
    					'event_start_time',
    					true
    				)
    			)
    		);
    	}
    );
    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    Pods saves all date and time fields as their compatible MySQL types https://dev.mysql.com/doc/refman/8.0/en/datetime.html

    So if you get 00:00:00 somewhere, then your display settings are not applied.

    I’m not sure how Elementor Dynamic Tags pulls content in, but you could also try enabling the settings at: Pods Admin > Settings > Performance

    To enable: Watch WP Metadata Calls and Override WP Metadata values.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Time format displaying with seconds’ is closed to new replies.