Skip to content

datetime timezone bug #203

Closed
Closed
@slene

Description

@slene

Go-MySQL-Driver version 1.0.3
go version go1.2 linux/amd64

Before version 1.0.3 (included) everything is ok. But after this version. Has a timezone bug.

example:

In linux:

# date
Fri Jan  3 14:49:44 CST 2014

In Mysql 5.5

mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | CST    |
| time_zone        | SYSTEM |
+------------------+--------+
mysql> SELECT @@session.time_zone;
+---------------------+
| @@session.time_zone |
+---------------------+
| SYSTEM              |
+---------------------+
mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2014-01-03 14:50:10 |
+---------------------+

In go

db, _ := sql.Open("mysql", "root:root@/orm_test?charset=utf8")
fmt.Println(time.Now())
res, _ := db.Exec("INSERT INTO doc (`time`)VALUES(?)", time.Now())
id, _ := res.LastInsertId()
fmt.Println(id)
var t string
db.QueryRow("SELECT `time` FROM doc WHERE id = ?", id).Scan(&t)
fmt.Println(t)

Before version 1.0.3 (included) output is

2014-01-03 14:55:50.430158786 +0800 CST
1
2014-01-03 14:55:50

Latest version output is. The timezone always is UTC. Can not detect the current timezone.

2014-01-03 14:59:31.729418163 +0800 CST
2
2014-01-03 06:59:31

What's wrong with this. May I miss something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions