SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Date formatting issue

    Can someone please help me?
    I have a date which is being echoed in the following format:

    Thu, 3 Oct 2013 11:15:06 +0100

    How can I get this to display like this 03 Oct?

    Any help greatly appreciated with this, Thanks in advance.

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Can you show the few lines echoing this?

  3. #3
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply Cups!

    The date is coming from an rss feed which I'm publishing on my webpage.
    All I'm doing to display the date is <?php echo $pubDate;?> and thats how it displays.

    Does that help any?

  4. #4
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,083
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    PHP Code:
    $date = new DateTime($pubDate);
    echo 
    $date->format('M m'); 
    Or, in PHP <5.3:

    PHP Code:
    $date strtotime($pubDate);
    echo 
    date('M m'$date); 
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  5. #5
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent!!

    Thanks very much for the help guys!

  6. #6
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    Quote Originally Posted by ScallioXTX View Post
    Or, in PHP <5.3:
    Your code will work just fine in any version of PHP that has the DateTime class: that is, PHP >= 5.2.0.
    Salathe
    Software Developer and PHP Manual Author.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •