SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    589
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    date() convert question

    Hello forum

    I have this code w/c queries latest dates of comments from a wordpress database

    Code PHP:
    $comments = get_comments('approve',comment_date_gmt,'DESC',5,0,None);
      foreach($comments as $comm):
     
         echo $comm->comment_date;
     
      endforeach;

    The above code will output (type of database data is date time):
    2010-01-08 04:02:16

    question is I want to reformat it to something like this:
    Jan 08, 2010 wednesday

    Any ideas?

    Thanks
    Don't Panic

  2. #2
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    strtotime() & date() functions

  3. #3
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    589
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh ok so you need to strtotime() it first before you date() it

    Code PHP:
    $a = '2010-01-08 04:02:16';
    echo  date('M d Y l ',strtotime($a));

    Thanks
    Don't Panic

  4. #4
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    echo date('M d, Y l'strtotime($comm->comment_date)); 
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


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
  •