Use regular expression in autoblogged to change date format

I have a a feed who’s date is formatted like ‘D, d M Y G:i:s e’

Autoblogged has a reg expression engine.

Read More

What is the regular expression to convert ‘D, d M Y G:i:s e’ to ‘F j, Y’?

Again I want to convert ‘Fri, 20 Apr 2012 12:00:00 EST’ to ‘April 20, 2012’ where the date is stored in variable %:pubDate%. I’m using Autoblogged for WordPress.

Related posts

Leave a Reply

1 comment

  1. Regex cannot convert strings, but it can find and parse them.
    This regex will do what you want.

    Put this in the “Search for” field (assuming that the dates are formatted exactly like Fri, 20 Apr 2012 12:00:00 EST):

    [a-zA-Z]{3}, ([0-9]{1,2}) ([a-zA-Z]{3}) ([0-9]{4}) [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2} [a-zA-Z]{3}
    

    And this in the “Replace with” field:

    $2 $1, $3
    

    See this for a demonstration: http://regex101.com/r/tP6hU7

    You can then replace

    • Jan(?:uary)? with January,
    • Feb(?:ruary)? with February,
    • etc.

    Input: Fri, 20 Apr 2012 12:00:00 EST
    Output: April 20, 2012