public static function sqlTime($timestamp = null) { if ($timestamp !== null && !is_numeric($timestamp)) { $timestamp = Time::time($timestamp); } return $timestamp ? date('H:i:s', $timestamp) : date('H:i:s'); }
/** * To return the time either artificial or correct. * @param boolean $realTime * @return int */ function time($mode = "CURR", $givenTime = 0) { if (strtoupper($mode) == "CURR") { //If mode is "CURR", return the correct user specified time. return Time::time(); } elseif (strtoupper($mode) == "SET") { //If mode is "SET", set the current time as specified by user. return Time::setTime($givenTime); } elseif (strtoupper($mode) == "RESET") { //If mode is "RESET", reset the time to the correct system time. return Time::resetTime(); } elseif (strtoupper($mode) == "MOV") { //If mode is "MOV", move the clock backward to the difference in time specified by the user. E.g. to move time backward 10 seconds, you will write phpsec\time("MOV", 10); return Time::moveTime($givenTime); } elseif (strtoupper($mode) == "SYS") { //If mode is "SYS", return the correct system time. return \time(); } else { return 0; } //If none of the mode matches, return 0. }
public static function set($time) { self::$time = $time; }
public function generate($time = null) { return $this->prefix . date('Ymd:Hi:', $time ?: Time::time()) . uniqid(getmypid(), true); }