for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* GpsLab component.
*
* @author Peter Gribanov <[email protected]>
* @copyright Copyright (c) 2016, Peter Gribanov
* @license http://opensource.org/licenses/MIT
*/
namespace GpsLab\Bundle\DateBundle;
class Converter
{
* @param mixed $date
* @return \DateTime
public function getDateTime($date)
if ($date instanceof \DateTimeInterface) {
$date = new \DateTime($date->format(\DateTime::ISO8601));
} elseif (is_numeric($date)) { // is UTS
$date = (new \DateTime())->setTimestamp($date);
} elseif (!($date instanceof \DateTime)) {
$date = new \DateTime($date);
}
return $date;