6/05/2014

MYSQL Unix time stamp conversion

When you want to convert the time stamp on mysql, please use the following code

1. time stamp to time
select FROM_UNIXTIME(1425933810);
+---------------------------+
| FROM_UNIXTIME(1425933810) |
+---------------------------+
| 2015-03-10 05:43:30       |
+---------------------------+
1 row in set (0.00 sec)

2. time to time stamp

select UNIX_TIMESTAMP('2015-11-06 10:10:10');
+---------------------------------------+
| UNIX_TIMESTAMP('2015-11-06 10:10:10') |
+---------------------------------------+
|                            1446772210 |
+---------------------------------------+
1 row in set (0.00 sec)

No comments:

Post a Comment