public function testGetDayTime() { $ts = 1424545971; // Saturday, 21-Feb-15 19:12:51 UTC $expected_ts = '69171'; $format = 'H:i:s'; $expected_format = '19:12:51'; $this->assertEquals($this->util->getTime($ts), $expected_ts); $this->assertEquals($this->util->getTime($ts, $format), $expected_format); }
/** * Calculates a timestamp by extracting time from $ts_time and adding it to the day start on $ts_day * * @param mixed $ts_time Date/time string containing time information * @param mixed $ts_day Date/time string containing day information * @return int */ public static function getTimeOfDay($ts_time = 0, $ts_day = null, $format = 'U', $tz = null) { if (!Util::isValidTimezone($tz)) { $tz = Util::getClientTimezone(); } $time = Util::getTime($ts_time, 'U', $tz); $day_start = Util::getDayStart($ts_day, 'U', $tz); $dt = new DateTime(null, new DateTimeZone($tz)); return $dt->setTimestamp($time + $day_start)->format($format); }