ok, a few days ago I posted about using a MySQL timestamp field. I needed to display the date associated with an entry in mm-dd-yyyy h:m a/p format
I thought I had it fixed using:
$row = mysql_fetch_array("SELECT posted, user_id FROM posts WHERE post_id = $post_id");
echo date("m-d-Y @g:i a",time ($row[posted]));
I realized that this was not working exactly right as every instance of this was showing up the current date/time... not exactly what I was looking for...
unfortunately MySQL stores timestamps in a way that is not compatible with PHP's date function. Another option I was given was to use:
$row = mysql_fetch_array("SELECT UNIX_TIMESTAMP(posted) as epoch time FROM posts WHERE post_id = $post_id");
echo date("m-d-Y @g:i a", ($row[posted]));
When I use that I get Jan 1 1976 or whatever time the unix epoch was...
How can I retrieve a timestamp column from a table and use it in PHP... can I simply reformat the table to use a more PHP friendly format? or is there some way to convert MySQL timestamps to something PHP can use?
I would have thought that as much as you see MySQL and PHP together (seemingly almost like they were designed to benefit each other in some sort of symbiotic relationship) that they would play together nicely in every aspect... maybe Im just not as bright as I like to think :p