本文整理匯總了PHP中Time::sec方法的典型用法代碼示例。如果您正苦於以下問題:PHP Time::sec方法的具體用法?PHP Time::sec怎麽用?PHP Time::sec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Time
的用法示例。
在下文中一共展示了Time::sec方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: relative
/**
* Время из строки
*
* @param string $format
* @param string $timezone
* @return int
*/
public static function relative($format, $timezone = null)
{
$time = 0;
if (preg_match('#^(?<sign>[+-]{1})?(?<number>\\d+)[ ]*(?<value>sec|min|hour|day|month|year)$#is', trim($format), $match) != 0) {
switch ($match['value']) {
case 'sec':
$time = Time::sec($match['number']);
break;
case 'min':
$time = Time::min($match['number']);
break;
case 'hour':
$time = Time::hour($match['number']);
break;
case 'day':
$time = Time::day($match['number']);
break;
case 'month':
$time = Time::month($match['number'], $timezone);
break;
case 'year':
$time = Time::year($match['number'], $timezone);
break;
}
if (isset($match['sign']) and $match['sign'] == '-') {
$time *= -1;
}
}
return $time;
}
示例2: toTime
/**
* Converts this instance to a proportion of time passed within a specified
* time interval where 360 degrees is equal to the interval.
*
* @param Time $interval
*
* @return Time
*/
public function toTime(Time $interval = null)
{
$secInDay = Time::days(1)->sec;
$interval = $interval ? $interval->sec : $secInDay;
return Time::sec($this->deg / 360 * $interval);
}
示例3: neg
/**
* Returns a new time with the negation of this instance.
*
* @return static
*/
public function neg()
{
return Time::sec($this->sec * -1);
}