datetime format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xiaawan
    New Member
    • May 2007
    • 17

    datetime format

    hi Everyone.
    Can anyone tell me how to change date format from mySql format to english like followings.

    value in db is 2007-05-19 00:00:00
    and I want it to be displayed in the following format.
    May 19 2007
    How can I achieve that.
    thanks in advance.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Take a look at date and strtotime.

    Comment

    • ianpitter
      New Member
      • Aug 2006
      • 11

      #3
      I've been struggling with this also having entered a time with NOW() into a field called place_date and then been unable to format it.
      The answer I have found which may not be the best but it works is as follows:

      [code=php]
      $mysqli = mysqli_connect( "localhost" , "user", "password", "db")

      $get = SELECT DATE_FORMAT(pla ce_date,' %b %e %Y ' ) AS fmt_place_date
      FROM table
      WHERE...;

      $get_res = mysqli_query($m yqsli,$get);

      $date = $get_res[' fmt_place_date'];

      echo $date;
      [/code]

      [Please use CODE tags when posting source code. Thanks! --pbmods]

      This is mostly cribbed from Julie Meloni's book PHP, MySQL and APACHE which, as a beginner, I have found very useful. (I don't know whether I'm allowed to say this but it's a genuine comment from the UK, not a promotional fluff!)
      Last edited by pbmods; May 27 '07, 04:01 PM. Reason: Added code tags.

      Comment

      Working...