Frank AK
Frank AK

Reputation: 1781

Why does the timestamp format change after I fetch it from table?

My table's structure:

+------------+---------------+------+-----+-------------------+----------------+
| Field      | Type          | Null | Key | Default           | Extra          |
+------------+---------------+------+-----+-------------------+----------------+
| f_id       | bigint(20)    | NO   | PRI | NULL              | auto_increment |
| f_uid      | bigint(20)    | NO   |     | NULL              |                |
| f_phone    | char(32)      | YES  |     | NULL              |                |
| f_username | char(64)      | YES  |     | NULL              |                |
| f_amount   | decimal(16,8) | NO   |     | NULL              |                |
| f_unspent  | decimal(16,8) | NO   |     | 0.00000000        |                |
| f_number   | int(11)       | NO   |     | NULL              |                |
| f_left     | int(11)       | NO   |     | 0                 |                |
| f_coin     | int(11)       | NO   |     | 0                 |                |
| f_message  | varchar(128)  | YES  |     | NULL              |                |
| f_accurate | int(11)       | NO   |     | 0                 |                |
| f_type     | int(11)       | NO   |     | 0                 |                |
| f_status   | int(11)       | NO   |     | 0                 |                |
| f_created  | timestamp     | NO   |     | CURRENT_TIMESTAMP |                |
| f_key      | char(64)      | YES  |     | NULL              |                |
+------------+---------------+------+-----+-------------------+----------------+

My sample data:

+------+--------+---------------------+
| f_id | f_uid  | f_created           |
+------+--------+---------------------+
|    1 | 123456 | 2018-08-14 10:33:52 |
+------+--------+---------------------+

And then, when I fetch the f_created value via Python API I have a different date format:

"Tue, 14 Aug 2018 10:33:52 GMT"

Why has happened? Any suggestions?

Upvotes: 0

Views: 29

Answers (1)

danblack
danblack

Reputation: 14736

When you've retrieved it in python you get a python datetime object. How this is printed is up to the datetime.strptime / strftime functions.

Upvotes: 3

Related Questions