MySQL data format to display format in PHP

Easty way to convert 2004-12-05 style date (mysql) to December 5, 2004 in PHP

//format date for printing
//I already have variable $mysqlDate which is 2004-12-05
//Remove the '-' from the standar MySQL sate format

list($Year,$Month,$Day) = split('-',$mysqlDate);

//Create a UNIX style timestamp from the result

$stampeddate = mktime(12,0,0,$Month,$Day,$Year);
$displayDate = date("F j, Y",$stampeddate);
print $displayDate;

I got this from a forum posting of njgMike99. You can do conversion when accessing mysql but it is easy for me to think in php even that means I need to convert it to unix timestamp once. Am I crazy?

Related posts:

  1. MySQL PHP example
  2. PHP memo to myself
  3. PHP Form
  4. MySQL
  5. Polling Survey Software
This entry was posted in Linux, Mac, and LAMP Open Source. Bookmark the permalink. Trackbacks are closed, but you can post a comment.

One Comment

  1. Posted Saturday, January 9, 2010 at 01/09/2010 @ 8:41 pm | Permalink

    here is a good website for formatting dates using the date_format function

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Welcome to Daigo’s Daily Digital Diorama. I blog about... whatever that comes to my mind.
  • Change color

    Purple Red Green Blue No Style

  • Archives

  • Calendar

    December 2004
    M T W T F S S
    « Nov   Jan »
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • Categories