I wrote this function to change the times displayed on my site based on the users timezone
function userTime($time, $timezone) {
$datetime = new DateTime($time, new DateTimeZone($timezone));
return $datetime->format("Y-m-d H:i:s");
}
echo userTime(date('Y-m-d H:i:s'), "America/New_ York");
The function works but to where it's spitting out a different time from the users actual location, am I doing something wrong or am I missing a step?