Home > Backend Development > PHP Tutorial > How to change the original timestamp format of the database to the 2016-07-10 09:15:42 format

How to change the original timestamp format of the database to the 2016-07-10 09:15:42 format

WBOY
Release: 2016-08-04 09:21:59
Original
1116 people have browsed it

The time field in a table in the database is in the form of a timestamp. I want to convert the timestamp into the format of 2016-07-10 09:15:42. Can I change it? How to change it?

Reply content:

The time field in a table in the database is in the form of a timestamp. I want to convert the timestamp into the format of 2016-07-10 09:15:42. Can I change it? How to change it?

update table set on_time = FROM_UNIXTIME(on_time,'%Y-%m-%d %H:%i:%s')

<code>date('Y-m-d H:i:s', 1156219870);</code>
Copy after login

The timestamp is stored in int(11)?
It seems that it cannot be changed. First create a field to store the time format data to be transferred

update table set formate_time = FROM_UNIXTIME(on_time,'%Y-%m-%d %H:%i:%s') This SQL verification is feasible.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template