Hi, I stored a date and time in a database using the mysql NOW() function. The field is of type datetime How can I use PHP to echo the stored value? I'm doing: $value = $row['order_DateTime']; echo $value; Code (markup): This doesn't work. I also tried: $value = $row['order_DateTime']; echo $value('l jS \of F Y h:i:s A'); Code (markup): Which also doesn't work. Can anyone help me with this? I always say thanks for help.
Just to make sure we're on the same page, is the value being stored in the database properly? Try a print_r of the whole $row array - does the key "order_DateTime" have a value? You're probably going to have to echo it as follows to get it in the date / time format (because it should be stored as a Unix Timestamp, right?): $value = $row['order_DateTime']; echo date('n/j/Y h:i:s',$value); PHP:
If you stored the data correctly, the this will output something like; $result = mysql_query("SELECT post_date FROM wp_posts where id=2") $row = mysql_fetch_array( $result ); print $row['post_date']."\n"; Code (markup): OUTPUT: 2010-04-21 08:34:47 You can chane the format of the output by using the date() function. http://uk2.php.net/manual/en/function.date.php If you arent getting any output, check the data in your database is correct first.