本文整理汇总了PHP中DateTimeHelper::now方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeHelper::now方法的具体用法?PHP DateTimeHelper::now怎么用?PHP DateTimeHelper::now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeHelper
的用法示例。
在下文中一共展示了DateTimeHelper::now方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create($input)
{
$primaryKeys = $this->getPrimaryKeys();
$existingModel = $this->find($input);
if (!empty($existingModel)) {
return $this->update($existingModel, $input);
}
foreach ($primaryKeys as $primaryKey) {
if (!array_key_exists($primaryKey, $input)) {
return null;
}
}
$modelClass = $this->getModelClassName();
$now = \DateTimeHelper::now();
if (!array_key_exists('created_at', $input)) {
$input['created_at'] = $now;
}
$input['updated_at'] = $now;
\DB::table($modelClass::getTableName())->insert($input);
return $this->find($input);
}
示例2: actionCreateGroup
public function actionCreateGroup()
{
/* validate all query string param */
$model = new Group('create');
$fileModel = new FileUploadFormModel();
$fileModel->setScenario(FileUploadFormModel::FILE_UPLOAD_MODE_SINGLE);
/*define the required variable for the controller base on the query string param */
if (isset($_POST['Group'])) {
$model->setAttributes($_POST['Group']);
//$fileHandler->LoadUploadedeImageToModel();
//$model->photos = $fileHandler->photos;
//$model->photos = CUploadedFile::getInstancesByName(BSMultiFileUploadWidget::fieldName);
if ($model->validate()) {
$fileModel->LoadUploadedeImage();
if ($fileModel->isUploadedFile()) {
if ($fileModel->validate()) {
$SavedFileRelativePaths = $fileModel->processImage(get_class($model), $model->group_name, md5(DateTimeHelper::now()));
$model->apply_img = ArrayHelper::array2string($SavedFileRelativePaths);
if ($model->save()) {
$model->addOwnerUser(Yii::app()->user->id);
Yii::app()->user->setFlash(FlashMsg::SUCCESS, "已提交組織申請");
$this->redirect(array('index'));
} else {
Yii::app()->user->setFlash(FlashMsg::ERROR, "提交組織申請失敗");
}
}
} else {
if ($model->save()) {
$model->addOwnerUser(Yii::app()->user->id);
Yii::app()->user->setFlash(FlashMsg::SUCCESS, "已提交組織申請");
$this->redirect(array('index'));
} else {
Yii::app()->user->setFlash(FlashMsg::ERROR, "提交組織申請失敗");
}
}
}
}
$this->render('createGroup', array('model' => $model, 'fileModel' => $fileModel));
}
示例3: addUserViewedIllust
/** @private-command-method */
private function addUserViewedIllust($userId)
{
$relation = new UserViewedIllust();
$relation->illust_id = $this->id;
$relation->user_id = $userId;
$relation->url_referrer = Yii::app()->request->urlReferrer;
$relation->view_datetime = DateTimeHelper::now();
$relation->count = 1;
$relation->save();
}
示例4: addOwnerUser
/** @relation-command */
public function addOwnerUser($userID)
{
$relation = new UserMemberGroup();
$relation->user_id = $userID;
$relation->group_id = $this->id;
$relation->joinded_datetime = DateTimeHelper::now();
$relation->is_leader = 1;
// remember to use 1 for boolean, using true will not make this record saving
$relation->is_approved = 1;
$relation->save();
}
示例5: actionJoinGroup
public function actionJoinGroup()
{
if (!isset($_POST['id'])) {
throw new CHttpException(404, 'The requested page does not exist.');
}
$groupIdToJoin = $_POST['id'];
$model = $this->loadModel($groupIdToJoin);
if ($model->isUserJoined(Yii::app()->user->id)) {
/** unexpected that user can call this action if it is either joined or pending*/
throw new CHttpException(404, 'The requested page does not exist.');
}
$relation = new UserMemberGroup();
$relation->user_id = Yii::app()->user->id;
$relation->group_id = $model->id;
$relation->joinded_datetime = DateTimeHelper::now();
$relation->is_leader = 0;
// remember to use 1 for boolean, using true will not make this record saving
$relation->is_approved = $model->isAutoApprove();
if ($relation->save()) {
$this->redirect(Yii::app()->request->urlReferrer);
}
}
示例6: getNewVersionNumber
/**
* @return string
*/
private function getNewVersionNumber()
{
return \DateTimeHelper::now()->format('U');
}
示例7: beforeSave
/** @callback */
protected function beforeSave()
{
if ($this->isNewRecord) {
$this->password = $this->createPassword();
$this->created_datetime = DateTimeHelper::now();
} elseif ($this->pwdChanged) {
$this->password = $this->createPassword();
}
return parent::beforeSave();
}