本文整理汇总了PHP中Nette\Utils\DateTime::getTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTime::getTimestamp方法的具体用法?PHP DateTime::getTimestamp怎么用?PHP DateTime::getTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\DateTime
的用法示例。
在下文中一共展示了DateTime::getTimestamp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Save past text into database
* Return generated hash
* @param array $data
* @return string
*/
public function save($data)
{
$data->hash = Random::generate(6, '0-9a-zA-Z');
$data->inserted = $this->dateTime->getTimestamp();
$data->id_user = '';
$this->dtb->table('pastes')->insert($data);
return $data->hash;
}
示例2: checkForTokenExpiration
/**
* @param Entities\UserEntity $e
* @param string $token
* @throws UserNotFoundException
* @throws ActivationLimitExpiredException
*/
public function checkForTokenExpiration(Entities\UserEntity $e, $token)
{
if ($e->token !== $token) {
throw new UserNotFoundException($this->translator->translate('locale.sign.incorrect_token'));
}
$current = new DateTime();
$created = $e->tokenCreatedAt;
$currentTimestamp = $current->getTimestamp();
$createdTimestamp = $created->getTimestamp();
$diff = $currentTimestamp - $createdTimestamp;
if ($diff >= Authenticator::ACTIVATION_LIMIT_TIMESTAMP) {
throw new ActivationLimitExpiredException($this->translator->translate('locale.sign.authentication_expired'));
}
}
示例3: getDateValue
/**
* Get Date from ::addDate() field
*
* @param Nette\Forms\Controls\TextInput|string $input
*
* @return string
*/
public static function getDateValue($input)
{
if ($input instanceof Nette\Forms\Controls\TextInput) {
$value = $input->getValue();
} else {
$value = $input;
}
if (preg_match('~^\\d{1,2}[/.]{1}[ ]{0,1}\\d{1,2}[/.]{1}[ ]{0,1}\\d{4}$~', $value, $arr)) {
$dateArr = preg_split('/[.\\/]{1}[ ]{0,1}/s', $arr[0]);
$date = new Nette\Utils\DateTime($dateArr[2] . '-' . $dateArr[1] . '-' . $dateArr[0]);
return $date->getTimestamp() < 10 ? NULL : $date->format('Y-m-d');
}
return empty($value) || $value == '0000-00-00' ? NULL : $value;
}