• mtjarrett

    (@mtjarrett)


    My site has a morning, midday, and evening podcast post every day. A listener would only want to listen to the podcast that is appropriate to the day and time. However, I am trying to make the podcasts available to people around the world (all time zones).

    Currently, I have my posts post exactly 1 day early. This works fine on my website though the back end is sloppy. What I am having problems doing is adjusting the post time on my feed. By far the majority of my listeners are in the US and I want the feed to simply show the correct post time for only central time zone.

    I am trying to adjust the feed date and time. This is how I am going about it:

    function get_early_post_time_for_feed ($id) {
    	$early_time = strtotime(get_the_time( 'D, d M Y H:i:s O' , $post = $id ));
    	$early_time = strtotime('-1 day', $early_time);
    	$early_time = date('D, d M Y H:i:s O', $early_time);
    	return ($early_time);
    }

    And here is the problem:
    echo get_early_post_time_for_feed (2121);
    Outputs:
    Mon, 27 Apr 2020 09:00:00 +0000

    But…
    echo get_the_time( 'D, d M Y H:i:s O', $post = 2121 );
    Outputs:
    Tue, 28 Apr 2020 04:00:00 -0500

    Why is the time off? And how can I fix it?

    I understand that the time is not technically “off”. But how do I make the function output look the same as the wordpress function output?

    And will this work for my feed?

    Thank you.

    • This topic was modified 6 years ago by mtjarrett.

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

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Adjusting post date by 1 day’ is closed to new replies.