Back to Totp class

Method getPeriod

public int
getPeriod
(mixed $time = null)
Get the time period based on the $time timestamp and the Time Step defined. If $time is skipped or set to null the current timestamp will be used.
Parameters
  • int|null $time Timestamp
Returns
  • int The time period since the UNIX Epoch
Class: Totp
Project: Joomla

Method getPeriod - Source code

/**
 * Get the time period based on the $time timestamp and the Time Step
 * defined. If $time is skipped or set to null the current timestamp will
 * be used.
 *
 * @param   int|null  $time  Timestamp
 *
 * @return  integer  The time period since the UNIX Epoch
 */
public function getPeriod($time = null)
{
    if (\is_null($time)) {
        $time = time();
    }
    $period = floor($time / $this->_timeStep);
    return $period;
}