I have a website where I display information from a mysql table such as date of last change. In mysql, the field type is 'TIMESTAMP' ... I have a code like this:
$postdate = date( "j F", strtotime( $row['insert_date'] ) ); // Getting the date from the database
$posthour = date( "H:i", strtotime( $row['insert_date'] ) ); // Getting the time from the database
if ($postdate == date("j F")) {$postdate = "Today";}
if ($postdate == date('j F', strtotime('-1 day'))) {$postdate = "Yesterday";}
if ($postdate == date('j F', strtotime('-2 day'))) {$postdate = "Day before yesterday";}
I have heard that strtotime is a slow function. Does anyone have any suggestions on how to rewrite this to improve performance in any way?
NOTE: the TIMESTAMP in mysql table may be changed if you suggest it, thats no problem!
Thanks