开发者

is it correct to use strtotime() to compare dates?

开发者 https://www.devze.com 2023-03-18 07:44 出处:网络
I have some problems with the following: <?php echo \"an issue by the function strtotime\".\"<br />\";

I have some problems with the following:

<?php
echo "an issue by the function strtotime"."<br />";
echo "01-30-2011 ======".strtotime(01-30-2011)."<br />";
echo "01/30/2011 ======".strtotime(01/30/2011)."<br />";
echo "07-01-2011 ======".strtotime(07-01-2011)."<br />";
echo "07/01/2011 ======".strtotime(07/01/2011)
?>

The result is an issue by the function strtotime:

01-30-2011 ======1310059868
01/30/2011 ======
07-01-2011 ======1310057768
07/01/2011 ======
  1. Whi开发者_开发知识库ch format is right to give argument to the function strtotime()?
  2. Why is the epoch value changing during the page refresh, even though the argument isn't changed?


The problem is that you aren't giving strtotime() strings! Put quotes around those parameters first.

echo "01-30-2011 ======".strtotime('01-30-2011')."<br />";
echo "01/30/2011 ======".strtotime('01/30/2011')."<br />";
echo "07-01-2011 ======".strtotime('07-01-2011')."<br />";
echo "07/01/2011 ======".strtotime('07/01/2011')
0

精彩评论

暂无评论...
验证码 换一张
取 消