public static function craftDateTime($seconds, $microseconds = 0)
 {
     // Override \Doctrine\ODM\MongoDB\Types\DateType::craftDateTime to return a DateTimeImmutable object
     // in the 'UTC' timezone instead the current PHP one (date_default_timezone_get())
     $datetime = new \DateTimeImmutable();
     $datetime->setTimezone(new \DateTimeZone('UTC'));
     $datetime->setTimestamp($seconds);
     if ($microseconds > 0) {
         $datetime = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s.u', $datetime->format('Y-m-d H:i:s') . '.' . $microseconds, new \DateTimeZone('UTC'));
     }
     return $datetime;
 }
 private static function getDate(\DateTime $dateTime)
 {
     $dateTimeImmutible = new \DateTimeImmutable();
     $dateTimeImmutible->setTimestamp($dateTime->getTimestamp());
     return $dateTimeImmutible;
 }
 public function testSetTimestamp()
 {
     $time = '2000-01-02T03:14:25';
     $immutable = new DateTimeImmutable($time);
     $control = new DateTimeImmutable($time);
     $mutable = new DateTime($time);
     $new = $immutable->setTimestamp(1272508903);
     $mutable->setTimestamp(1272508903);
     $this->assertNotSame($immutable, $new);
     $this->assertSame($control->format(DateTime::RFC3339), $immutable->format(DateTime::RFC3339));
     $this->assertSame($mutable->format(DateTime::RFC3339), $new->format(DateTime::RFC3339));
 }