/** * @covers alroniks\dtms\DateTime::format */ public function testFormat() { $dt = new DateTime('2015-08-08 10:10:10.123456'); $this->assertSame('08.08.2015 10:10:10.123456', $dt->format('d.m.Y H:i:s.u')); $this->assertSame('08.08.2015 10:10:10', $dt->format('d.m.Y H:i:s')); $this->assertSame('1439028610.123456', $dt->format('U.u')); }
/** * Returns date formatted according to given format. * * @param string $format * @return string */ public function format($format) { $format = str_replace('u', sprintf('%06d', $this->microseconds), $format); return parent::format($format); }