DISQUS

Tech-Recipes: Get MySQL date in RFC-822 format for RSS feeds | MySQL | Tech-Recipes

  • Anonymous · 1 year ago
    Don't use the php DATE('T') if your (tally ho chaps) british, in winter your feed will validate and general work fine, however in sping when day light savings time kicks in it will mysteriously break. PHP pust your timezone as BST or "British Summer Time" which will not validate, where as GMT (grewnich mean time) does.

    You have no idea how long it too me to twig what was wrong...

    Tom
  • Damian · 5 months ago
    Found this very helpful. The only one thing I would say is that if you try and use ORDERBY rfcpubate DESC in the MYSQL query something weird happens and it doesn't select the most recent. To fix i did this:

    SELECT pubdate, DATE_FORMAT(pubdate,'%a, %d %b %Y %T') AS rfcpubdate FROM tablename ORDERBY pubdate DESC

    very helpful indeed though
  • Jannick Bolten · 3 months ago
    Thank you! I'm using it :-)
  • Marcello Orizi · 2 months ago
    Hi all,
    to add the correct timezone formatted in RFC-822 format in Java I found this method. I don't like it too much because it requires to call cal.getTime() everytime but it seems to do what needed.

    import java.util.Calendar;
    import java.text.SimpleDateFormat;

    public class foo{
    public static final String DATE_FORMAT_RFC822_TIMEZONE = "Z";

    public String getRFC822TimeZone() {
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_RFC822_TIMEZONE);
    return sdf.format(cal.getTime());
    }

    }