小小的问题
为什么这样也echo错误呢
$date1 = "Apr/13/2012";
$date2 = "Apr/6/2012";
if($date1 > $date2){
echo "正确";
}else{
echo "错误"."<script>alert('错误');</script>";
}
?>
------解决方案--------------------
你比较的是字符串,又不是数字。$date1与$date2第一个不同的字符是"1" and "6".
"1"的ascii 码比"6"的ascii小,当然date1>date2!
比较前先把字符串转换为时间戳(strtotime)
<?php $date1 = "Apr/13/2012";
$date2 = "Apr/6/2012";
if(strtotime($date1) > strtotime($date2)){
echo "正确";
}else{
echo "错误"."<script>alert('错误');</script>";
}
?>
<br><font color="#e78608">------解决方案--------------------</font><br>字符串好像是不能比较大小吧!!
<br><font color="#e78608">------解决方案--------------------</font><br>标准时间格式没有你这样的写法:Apr/13/2012<br>应该是这种:Apr 13 2012<br>这种:4/13/2012<br>或者是这种:2012-4-13<br>或者:..... <div class="clear"></div>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号