Do you have a question? Post it now! No Registration Necessary. Now with pictures!
February 16, 2005, 6:14 am
rate this thread
I have a MySQL table with a datetime field that stamps the time the user
submitted the form. It works and looks like this:
$sql = "INSERT INTO table
On another php page to view results, the code:
makes it looks like: 2005-02-15 14:44:51
I want it to look like:
Wednesday 15th of January 2005 05:51:38 AM
but when I try "date("l dS of F Y h:i:s A");" I get the format, but with
the CURRENT time. I can't get the time stamped in that format. Thanks.
Re: PHP / MySQL time format
Of course you get the current time. You need to pass a timestamp to the
date() function to get a spefic date and time like so:
date("l dS of F Y h:i:s A", strtotime($newArray["datetime"]));
The strtotime() function converts the mysql datetime into a timestamp
suitable for passing to date().
or else format the date and time directly in your query with the MySQL
function DATE_FORMAT. More info about this here:
And there's also this article I wrote:
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com /