i put date in mysql database with this method 2012-08-02 02:20:05. now, how to print in my page using smarty.
mycode : ( NOTE: send_date is name of row )
$sql = "SELECT m.*, s.photo, s.gender
FROM mail AS m, signup AS s
WHERE m.receiver = '" .mysql_real_escape_string($username). "'
AND m.sender = s.username AND inbox = '1' AND status = '1'
ORDER BY send_date DESC LIMIT " .$limit;
$rs = $conn->execute($sql);
To convert a date from
2012-08-02 02:20:05to unix epoch (seconds since 1970), you want to use strtotime(). To format an epoch to any human readable date you want to use date() or strtotime().Smarty knows the date_format modifier. Since Smarty3 this puppy accepts pretty much anything that represents a date (including
2012-08-02 02:20:05). In Smarty2 you might need to convert the string to epoch yourself, something like {$date|strtotime|date_forma:”%d.$m.%Y”}. Note that since Smarty3 date_format accepts format notations from strtotime and date, while Smarty2 only supported the strtotime notation.