WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Reformat date/time from feed (3 posts)

  1. artfulalibi
    Member
    Posted 5 years ago #

    Hello,

    I am using the fetch_rss() native to WP to grab my twitter feed. However, the publish date comes through in a much longer format than I like. Does anyone know if there is a way to manipulate this parsed date using PHP, or is there a file I can alter?

    The date comes in as part of an array $item['pubdate'], and echos out as Tue, 30 Dec 2008 05:47:11 +0000

    I like it to be more like, Dec 30 - 5:47.

    Any help would be great!

    PS. If you are wondering why I don't use one of the great plugins already developed for twitter ~ I needed a plugin that supports an offset of posts, which none of them do. Fetch_rss() does.

    Thanks everyone.

  2. artfulalibi
    Member
    Posted 5 years ago #

    Well,

    I found my answer in another forum after more searching.

    For any that are curious:
    $reformdate = date("Y-m-d", strtotime($item['pubdate']));

    The strtotime, converts the string into the a Unix timestamp, from which you can apply it to the standard date function and reformat it however you like.

    Geeking out here!

  3. tkm
    Member
    Posted 5 years ago #

    Hi artfulalibi,

    So, is there a way to remove the timestamp completely and just have the date i.e. "Y-m-d"?

Topic Closed

This topic has been closed to new replies.

About this Topic