PHP和MySQL将所有日期行更新为时间戳

时间:2016-02-02 12:20:53

标签: php mysql

我有一个数据库,结构看起来像

[Name] [18:00]
[Name] [12:00]

我希望每次都使用strtotime转换为时间戳。我该怎么办?我尝试while循环,它为每个人设置相同的时间。

2 个答案:

答案 0 :(得分:0)

您可以尝试以下内容,只需为表和列提供正确的名称。

update `<TABLE>` set `<FIELD>`=unix_timestamp( concat( date_format( now(), "%Y-%m-%d"), " ", `<FIELD>`, ":00" ) );

或者,现在看过pastbin数据

update `times` set `book_date`=unix_timestamp( concat( date_format( now(), "%Y-%m-%d"), " ", `book_date`, ":00" ) );

答案 1 :(得分:0)

if(isset($_POST['update'])){
    for($i=0;$i<$count;$i++){
        $result = dbquery("UPDATE times SET.....");
    }
}

这就是我所需要的。这是帮助我用唯一的新值更新每个值的解决方案。这就是全部所需。

相关问题