Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    911
    Thanks
    302
    Thanked 2 Times in 2 Posts

    Question MySQL Timestamp into PHP Format

    I have a timestamp column in a mysql table.

    Using PHP, how do I convert the timestamp format which is "YYYY-MM-DD HH:MM:SS" into a format like "March 16 2008, 08:41 am" ?


    Please help



    Thanx

  • #2
    New Coder
    Join Date
    Dec 2005
    Posts
    35
    Thanks
    1
    Thanked 1 Time in 1 Post
    http://uk.php.net/date has a list of all the available date functions.

  • Users who have thanked InsaneRhino for this post:

    phantom007 (03-17-2008)

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,018
    Thanks
    2
    Thanked 313 Times in 305 Posts
    Use the mysql date_format() function in your select query - http://dev.mysql.com/doc/refman/5.0/...on_date-format

    If you do this using slow php code, you must use a strtotime() function and a date() function to end up with the same results as one mysql function.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • Users who have thanked CFMaBiSmAd for this post:

    phantom007 (03-17-2008)

  • #4
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    911
    Thanks
    302
    Thanked 2 Times in 2 Posts
    Yes, I have looked into that already. Doesnt solve my purpose.

  • #5
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Code:
    date_format(date_column, '%M %d %Y, %l:%i %p');
    How does this not solve your purpose?
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.


  •  

    Posting Permissions

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