date/time formatting

    Date: 04/22/06 (PHP Community)    Keywords: php, mysql, database, sql

    In my MySQL database is a field realdate of type datetime. I am trying to convert that string (yyyy-mm-dd hh:mm) into a different format using PHP. The format I want is d/m/yy, h:mm which I gather from the manual is specified by this: j/n/y, g:i.

    Question is, how do I use PHP to format the string that MySQL outputs?

    Outputting the string without any manipulation produces the correct dates/times. When I try using date() all my dates read 1/1/70, 10:00. No difference when I tried using strtotime().
    $post_realdate_raw = $post_result['realdate'];
    $post_realdate = date("j/n/y, g:i", $post_realdate_raw);


    If anyone would be so kind as to explain what I'm doing wrong, I would be most grateful. TIA!

    Source: http://community.livejournal.com/php/442458.html

« Unusable column names? || Is there a better way of... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home