/** * "hh:mm" 形式の文字列を返すことを確認します. * @covers Peach\DT\Datetime::formatTime */ public function testFormatTime() { $d = new Datetime(2012, 5, 21, 7, 30); $this->assertSame("07:30", $d->formatTime()); }
/** * このオブジェクトの時刻部分の文字列を "hh:mm:ss" 形式で返します. * @return string "hh:mm:ss" 形式の文字列 */ public function formatTime() { $format = parent::formatTime(); $sec = str_pad($this->second, 2, '0', STR_PAD_LEFT); return $format . ":" . $sec; }