I’m trying to display mysql stored unix timestamp values on my browser (and also save them to a CSV file). The values are stored as int (11). The problem is that when I display them, I see ‘d’, ‘P’, ‘j’, ‘M’ and other characters that are used for formatting dates instead of the actual timestamp. What’s going wrong ?
<?php
/* MySQL connection and database connection code */
mysql_query ("SELECT emailaddress, subscribedate FROM email_list_subscribers WHERE subscriberid = '$sid'");
$email_result= mysql_query ("SELECT emailaddress, subscribedate FROM email_list_subscribers WHERE subscriberid = '$sid'");
if (mysql_num_rows ($email_result) == 0) {
$email = '';
$subscribedate = '';
} else {
$email = mysql_fetch_assoc ($email_result);
$email = $email['emailaddress'];
$subscribedate = (string) ( $email['subscribedate']);
echo $sid . " : " . $subscribedate . "<br/>";
}
?>
You have to convert the timestamp value to a datetime in order to show the formated info:
also you can use:
Be careful, you have to take into account the timezone