Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed date to real GMT (UTC) #116

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions migrations/m150214_044831_init_user.php
Expand Up @@ -81,8 +81,8 @@ public function safeUp()
// insert role data
$columns = ['name', 'can_admin', 'create_time'];
$this->batchInsert('{{%role}}', $columns, [
['Admin', 1, date('Y-m-d H:i:s')],
['User', 0, date('Y-m-d H:i:s')],
['Admin', 1, gmdate('Y-m-d H:i:s')],
['User', 0, gmdate('Y-m-d H:i:s')],
]);

// insert admin user: neo/neo
Expand All @@ -95,7 +95,7 @@ public function safeUp()
'neo',
'$2y$13$dyVw4WkZGkABf2UrGWrhHO4ZmVBv.K4puhOL59Y9jQhIdj63TlV.O', // neo
User::STATUS_ACTIVE,
date('Y-m-d H:i:s'),
gmdate('Y-m-d H:i:s'),
$security->generateRandomString(),
$security->generateRandomString(),
],
Expand All @@ -104,7 +104,7 @@ public function safeUp()
// insert profile data
$columns = ['user_id', 'full_name', 'create_time'];
$this->batchInsert('{{%profile}}', $columns, [
[1, 'the one', date('Y-m-d H:i:s')],
[1, 'the one', gmdate('Y-m-d H:i:s')],
]);
}

Expand Down
2 changes: 1 addition & 1 deletion models/Profile.php
Expand Up @@ -61,7 +61,7 @@ public function behaviors()
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'value' => function () { return date("Y-m-d H:i:s"); },
'value' => function () { return gmdate("Y-m-d H:i:s"); },
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => 'create_time',
ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time',
Expand Down
2 changes: 1 addition & 1 deletion models/Role.php
Expand Up @@ -81,7 +81,7 @@ public function behaviors()
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'value' => function () { return date("Y-m-d H:i:s"); },
'value' => function () { return gmdate("Y-m-d H:i:s"); },
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => 'create_time',
ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time',
Expand Down
6 changes: 3 additions & 3 deletions models/User.php
Expand Up @@ -172,7 +172,7 @@ public function behaviors()
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'value' => function () { return date("Y-m-d H:i:s"); },
'value' => function () { return gmdate("Y-m-d H:i:s"); },
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => 'create_time',
ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time',
Expand Down Expand Up @@ -298,7 +298,7 @@ public function beforeSave($insert)

// convert ban_time checkbox to date
if ($this->ban_time) {
$this->ban_time = date("Y-m-d H:i:s");
$this->ban_time = gmdate("Y-m-d H:i:s");
}

// ensure fields are null so they won't get set as empty string
Expand Down Expand Up @@ -385,7 +385,7 @@ public function updateLoginMeta()
{
// set data
$this->login_ip = Yii::$app->getRequest()->getUserIP();
$this->login_time = date("Y-m-d H:i:s");
$this->login_time = gmdate("Y-m-d H:i:s");

// save and return
return $this->save(false, ["login_ip", "login_time"]);
Expand Down
2 changes: 1 addition & 1 deletion models/UserAuth.php
Expand Up @@ -70,7 +70,7 @@ public function behaviors()
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'value' => function () { return date("Y-m-d H:i:s"); },
'value' => function () { return gmdate("Y-m-d H:i:s"); },
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => 'create_time',
ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time',
Expand Down
12 changes: 6 additions & 6 deletions models/UserKey.php
Expand Up @@ -85,7 +85,7 @@ public function behaviors()
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'value' => function () { return date("Y-m-d H:i:s"); },
'value' => function () { return gmdate("Y-m-d H:i:s"); },
'attributes' => [
// set only create_time because there is no update_time
ActiveRecord::EVENT_BEFORE_INSERT => ['create_time'],
Expand Down Expand Up @@ -123,7 +123,7 @@ public static function generate($userId, $type, $expireTime = null)
// set/update data
$model->user_id = $userId;
$model->type = $type;
$model->create_time = date("Y-m-d H:i:s");
$model->create_time = gmdate("Y-m-d H:i:s");
$model->expire_time = $expireTime;
$model->key_value = Yii::$app->security->generateRandomString();
$model->save(false);
Expand All @@ -139,7 +139,7 @@ public static function generate($userId, $type, $expireTime = null)
*/
public static function findActiveByUser($userId, $type)
{
$now = date("Y-m-d H:i:s");
$now = gmdate("Y-m-d H:i:s");
return static::find()
->where([
"user_id" => $userId,
Expand All @@ -159,7 +159,7 @@ public static function findActiveByUser($userId, $type)
*/
public static function findActiveByKey($key, $type)
{
$now = date("Y-m-d H:i:s");
$now = gmdate("Y-m-d H:i:s");
return static::find()
->where([
"key_value" => $key,
Expand All @@ -177,7 +177,7 @@ public static function findActiveByKey($key, $type)
*/
public function consume()
{
$this->consume_time = date("Y-m-d H:i:s");
$this->consume_time = gmdate("Y-m-d H:i:s");
$this->save(false);
return $this;
}
Expand All @@ -189,7 +189,7 @@ public function consume()
*/
public function expire()
{
$this->expire_time = date("Y-m-d H:i:s");
$this->expire_time = gmdate("Y-m-d H:i:s");
$this->save(false);
return $this;
}
Expand Down