本文整理匯總了PHP中Cake\I18n\Time::addMonths方法的典型用法代碼示例。如果您正苦於以下問題:PHP Time::addMonths方法的具體用法?PHP Time::addMonths怎麽用?PHP Time::addMonths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\I18n\Time
的用法示例。
在下文中一共展示了Time::addMonths方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _updateUser
/**
* Update the end subscription date of the user.
*
* @param array $custom The custom data passed to Paypal.
*
* @return bool|\App\Model\Entity\User
*/
protected function _updateUser(array $custom)
{
$this->_controller->loadModel('Users');
$user = $this->_controller->Users->find()->where(['id' => $custom['user_id']])->first();
if (!$user) {
Log::error(__('This user does not exist.'), 'paypal');
return false;
}
if ($user->premium) {
$this->_action = 'extend';
$end = $user->end_subscription;
$date = new Time($end);
} else {
$date = new Time();
}
$date->addMonths($custom['period']);
$data = ['end_subscription' => $date];
$this->_controller->Users->patchEntity($user, $data);
$this->_controller->Users->save($user);
return $user;
}