drh78568 2016-08-08 06:59
浏览 16

时间输入验证/当我输入intime 10:30或9:30两者都被接受但在PHP中条件不正确

foreach ( $period as $dt )
{
    $new=$dt->format("Y-m-d");
    $sql1=mysql_query("SELECT * FROM enginner_timesheet e, cz c
            WHERE e.enginner_name='$name'
               and c.fullname='$fullname'
               and e.date='$new' ");            
    $row2= mysql_fetch_array($sql1);

    $in_time=$row2["in_time"];
    // if the condition apply
    if ($in_time > "10:20")
          $in_time = "<font color='#FF0000'>" .$in_time. "</font>";
    //if the condition met than time font will be red

    echo "<td>".$in_time."-".$row2["out_time"]."-".$row2["other_details"]."</td>";
} 

I want to require if the condition is true than font text will be red but my output differs. The value is shown in red but 10:23 shows in red and 9:23 also shows in red.

  • 写回答

1条回答 默认 最新

  • dongpo4197 2016-08-08 07:23
    关注

    try this way

    if(strtotime($in_time)>strtotime("10:20"))
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用