public function testDateConversion()
 {
     /* Classic DateTime ---------------------------------------------------------------------------- */
     $og = $this->getDummy();
     $dateTime = new DateTime();
     $dateTime->setTimestamp(1234567890);
     $og->tag('datetime', $dateTime);
     $tag = $og->lastTag('datetime');
     $value = $tag->value;
     // ISO 8601 - summer/winter time
     $this->assertTrue($value === '2009-02-13T23:31:30+0000' || $value === '2009-02-14T00:31:30+0100');
     /* Carbon -------------------------------------------------------------------------------------- */
     $carbon = new Carbon\Carbon();
     $carbon->setTimestamp(1234567890);
     $og->tag('datetime', $carbon);
     $tag = $og->lastTag('datetime');
     $value = $tag->value;
     // ISO 8601 - summer/winter time
     $this->assertTrue($value === '2009-02-13T23:31:30+0000' || $value === '2009-02-14T00:31:30+0100');
 }
Example #2
0
 /**
  * @param $timestamp
  * @return \DateTime|\Pimcore\Date
  */
 protected function getDateFromTimestamp($timestamp)
 {
     if (\Pimcore\Config::getFlag("useZendDate")) {
         $date = new \Pimcore\Date($timestamp);
     } else {
         $date = new \Carbon\Carbon();
         $date->setTimestamp($timestamp);
     }
     return $date;
 }