2011-07-06 8 views
0

私は、次のいくつかの問題があります。結果は、関数のstrtotimeによって 問題ですstrtotime()を使って日付を比較するのは正しいですか?

<?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) 
?> 

を:フォーマットは、関数のstrtotime(に引数を与えるために適切である

01-30-2011 ======1310059868 
01/30/2011 ====== 
07-01-2011 ======1310057768 
07/01/2011 ====== 
  1. ) ?
  2. 引数が変更されていないのに、ページの更新中にエポック値が変化するのはなぜですか?

答えて

1

問題は、strtotime()文字列を指定していないことです。これらのパラメータの前後に引用符を入れてください。

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

ありがとうございました。 – gayathri

関連する問題