the time insert into sqlite3 always is UTC time #585

Closed
opened 2017-05-12 02:31:02 +00:00 by ciys · 2 comments
ciys commented 2017-05-12 02:31:02 +00:00 (Migrated from github.com)
type User struct{
   Id string
   OperTime time.Time
}
user : = User{}
user.OperTime = time.Now()
session.Insert(&user)

the OperTime always is UTC time.If i change code like this:

type User struct{
   Id string
   OperTime time.Time `xorm:"created"`
}
user : = User{}
session.Insert(&user)

It still is UTC time.
And I change the engine time zone ,it still is UTC time

engine.TZLocation = time.Local
engine.DatabaseTZ= time.Local

or

engine.TZLocation = time.LoadLocation("Asia/Shanghai")
engine.DatabaseTZ= time.LoadLocation("Asia/Shanghai")

But if i use

engine.Exec("insert into user (id,oper_time) values (?,?)",id,time.Now())

it can insert into right time.Is that a bug?

```golang type User struct{ Id string OperTime time.Time } user : = User{} user.OperTime = time.Now() session.Insert(&user) ``` the OperTime always is UTC time.If i change code like this: ```golang type User struct{ Id string OperTime time.Time `xorm:"created"` } user : = User{} session.Insert(&user) ``` It still is UTC time. And I change the engine time zone ,it still is UTC time ```golang engine.TZLocation = time.Local engine.DatabaseTZ= time.Local ``` or ```golang engine.TZLocation = time.LoadLocation("Asia/Shanghai") engine.DatabaseTZ= time.LoadLocation("Asia/Shanghai") ``` But if i use ```golang engine.Exec("insert into user (id,oper_time) values (?,?)",id,time.Now()) ``` it can insert into right time.Is that a bug?
ciys commented 2017-05-25 01:58:02 +00:00 (Migrated from github.com)

anybody can help me?

anybody can help me?

Please fetch the latest commit and engine.DatabaseTZ= time.Local will now resolve your problem.

Please fetch the latest commit and `engine.DatabaseTZ= time.Local` will now resolve your problem.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#585
No description provided.