Ok here is a new function I have made that returns the same value but works with a user timezone setting, this works with the mysql datetime field, maybe there is a better way to do this anyone??
<?PHP
/*##########################################################################################
# Returns a MySQL datetime as Jul 18, 2009 11:05 PM and adjust to a users timezone setting #
###########################################################################################*/
function datetime($datetime = 0, $timezone = 0.0) {
$datetime = strtotime($datetime);
$newdatetime = $datetime + ($timezone * 3600);
$formateddatetime = date("M d, Y H:i:s A", $newdatetime);
return $formateddatetime;
}
$date = '2009-07-04 21:33:11';
$timezone = 7;
echo datetime($date,$timezone);
?>
After some research, it seems strtotime() is not the greatest for performance on a high traffic social network site, so I have another question, instead of using DATETIME to store these in mysql, I read that some peole store a unix timestamp into a regular INT field, I could easily do this but it would break a couple other functions I use. One thing I do often is I will run a mysql query that gets results that are for example 7 days and newer or all results within X amount of days, this is very easy to do with a DATETIME in mysql, would I be able to do this easily with a regular timestamp?