【问题标题】:How to Join a date filed with a time field in php如何在php中加入带有时间字段的日期
【发布时间】:2017-04-20 05:08:46
【问题描述】:

我需要加入日期字段bid_staring_date 和时间字段bid_staring_time 并检查当前日期时间$current_date_time=date('M d,Y H:i:s'); 我该怎么做?

<?php 
    $current_date_time=date('M d,Y H:i:s');
    $bid_schedule_date=date('M d,Y',strtotime($row['bid_staring_date']));
    $bid_schedule_time=date('H:i:s',strtotime($row['bid_staring_time']));
    echo $bid_schedule_date_time=date('M d,Y H:i:s',(strtotime($bid_schedule_date)+strtotime($bid_schedule_time)));
    $bid_schedule_id=$row['bid_schedule_id'];

    if($current_date_time>=$bid_schedule_date_time){
        $btn_type="btn btn-success";
        $btn_value="Bid Now";
        $btn_link="openbid.php?pid=$bid_schedule_id";                                                                       
    } 
    else
    {
        $btn_type="btn btn-danger";
        $btn_value="Bid Not Started";
        $btn_link="#";                                                                      
    }
    echo "<a href='$btn_link' class='$btn_type'>$btn_value</a>";
?>

【问题讨论】:

  • 不清楚您的问题。要不要将此行的“(strtotime($bid_schedule_date)+strtotime($bid_schedule_time))”连接起来?
  • 将日期和时间存储为单个实体
  • 2017-04-22 | 11:56:00 | 00:30:00

标签: php mysql date time


【解决方案1】:
   $game_date = game['date'];
   $game_time = game['time'];

    $combined_date_and_time = $game_date . ' ' . $game_time;
    $past_date = strtotime($combined_date_and_time);

参考 :: Take two variables for Date and Time and combine to make one date

【讨论】:

    【解决方案2】:

    【讨论】:

    • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
    • 对不起,链接是什么??
    猜你喜欢
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多