This blog site is not meant to be any information that is distributed to the general public. It is to serve as shared documentation between the DNSTC developers; however, if you find something useful and would like to use it, go right ahead.

Monday, January 2, 2012

Formatting MySQL datetime field in PHP

If you would like to get a nice format on the datetime field stored in MySQL, use the following code:


    $datetime = strtotime($row_links['dateAdded']); // The date time field
    $formatDate = date("m/d/y g:i A", $datetime);
    echo $formatDate;


This will output something like:

01/01/12 8:07 PM

If you want more formatting options for the date(), you can review the manual on here.

No comments:

Post a Comment