/** * Convert a date (number) to a database date representation (string). * * @param long dateTime The date (number) * @param boolean whether the returned string should be surrounted by quotes. * @return string */ public static function convertDate($dateTime, $timeZone = 'GMT', $withQuotes = true) { if ($dateTime == null) { return $withQuotes ? "null" : null; } $format = new Formatter($timeZone); $sDate = $format->dateFormat($dateTime, "Y-m-d H:i:s"); return $withQuotes ? "'{$sDate}'" : $sDate; }
/** * @covers Formatter::dateFormat */ public function testDateFormatException() { $formatter = new \Formatter('Mars/Phobos', "fr_Fr"); $actual = $formatter->dateFormat("1430469263", "Y-m-d H:i:s"); $this->assertEmpty($actual); }