当前位置: 代码迷 >> PHP >> mysql时间存储有关问题
  详细解决方案

mysql时间存储有关问题

热度:110   发布时间:2012-05-11 12:55:37.0
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 类型字段的数据
  相关解决方案