DateTimeHelper.php 420 B

123456789101112131415161718192021
  1. <?php
  2. namespace fphammerle\helpers;
  3. class DateTimeHelper
  4. {
  5. /**
  6. * @param integer|null $timestamp unix timestamp
  7. * @return DateTime|null
  8. */
  9. public static function timestampToDateTime($timestamp)
  10. {
  11. if($timestamp === null) {
  12. return null;
  13. } else {
  14. $dt = new \DateTime();
  15. $dt->setTimestamp($timestamp);
  16. return $dt;
  17. }
  18. }
  19. }