I have a mailer to send on reminder stating the clients last login date. My time is saved in unixtimestamp. So when I fetch from the database and include it in the email then it is giving me 6 days before date. What am I doing wrong here?
Part of the data:
$lastlogin = mysql_result($result,$i,"lastlogin");
$newlastlogin = date("d-m-Y", $lastlogin);
Email Body:
$msg .= "Your Last Activity: $newlastlogin.<BR>";
lastlogin from mysql has date of 27-05-2012
But when the mail goes, then it shows 21-05-2012
By the way, I tried with
$newlastlogin = date("d-m-Y", strtotime($lastlogin));
Any help and advise would be appreciated
You can convert the date to a Unix TimeStamp directly from the database using
unix_timestamp(date) on your select statement.
example: (asuming you have a field named last_login on a logins table)
Details here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_unix-timestamp