Deserialize.php 522 B

12345678910111213141516171819202122
  1. <?php
  2. namespace Twilio;
  3. class Deserialize {
  4. /**
  5. * Deserialize a string date into a DateTime object
  6. *
  7. * @param string $s A date or date and time, can be iso8601, rfc2822,
  8. * YYYY-MM-DD format.
  9. * @return \DateTime DateTime corresponding to the input string, in UTC time.
  10. */
  11. public static function dateTime($s) {
  12. try {
  13. return new \DateTime($s, new \DateTimeZone('UTC'));
  14. } catch (\Exception $e) {
  15. return $s;
  16. }
  17. }
  18. }