0

Simple question, but still didn't found the answer. I'm storing the records in a table with one field as current timestamp (the field type is timestamp). However, when I do a SELECT, the value returned is a formatted string (like this: 2013-06-26 10:07:06), and I need the number so I can convert to another kind of date. Is there some mySQL setup, or instruction, or a php instruction?

4

2 回答 2

1

如果需要,您可以strtotime($timestamp)在 php 中使用将其转换为时间戳。

于 2013-06-28T19:17:29.660 回答
1

您可以将其转换为 unix 时间戳(自 '1970-01-01 00:00:00' UTC 以来的秒数):

SELECT UNIX_TIMESTAMP(Col1)
FROM   yourtable
于 2013-06-28T19:19:01.567 回答