我有一个结构如下的数据库
[Name] [18:00]
[Name] [12:00]
我想相应地使用 strtotime 将每个时间转换为时间戳。请问我该怎么做?我尝试了 while 循环,它为每个人设置了相同的时间。
最佳答案
您可以尝试类似以下的操作,只需为表和列提供正确的名称即可。
update `<TABLE>` set `<FIELD>`=unix_timestamp( concat( date_format( now(), "%Y-%m-%d"), " ", `<FIELD>`, ":00" ) );
或者,现在已经看到过去的数据
update `times` set `book_date`=unix_timestamp( concat( date_format( now(), "%Y-%m-%d"), " ", `book_date`, ":00" ) );
关于PHP 和 MySQL 将所有日期行更新为时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35153382/