Home  >  Article  >  Backend Development  >  mysql时间存储有关问题

mysql时间存储有关问题

WBOY
WBOYOriginal
2016-06-13 13:32:061185browse

mysql时间存储问题
时间前台显示 xx时xx分 时间是前台填写的 怎么存进数据库和读取?

------解决方案--------------------
有字段类型是什么类型啊。存成对应的类型格式就好了啊

像DATE xxxx-xx-xx
DATETIME xxxx-xx-xx xx:xx:xx
TIME xx:xx:xx

------解决方案--------------------
$s = '16时48分';
//$s = '16:48';
echo date('H:i:s' , strtotime(preg_replace('/[^\d]/', '', $s)));

得到 16:48:00
这就是你需要写入 time 类型字段的数据

Statement:
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