<?php function getTZType(\DateTime $date) { ob_start(); var_export($date); $dateString = ob_get_clean(); preg_match('%=>.\d%', $dateString, $matches); return (int)explode(' ', $matches[0])[1]; } $date = new \DateTime('2014-01-13 04:22 -8'); echo getTZType($date) . "\n"; $date = new \DateTime('2014-01-13 04:22'); echo getTZType($date);
You have javascript disabled. You will not be able to edit any code.