PHP Statement Date comparison problem
How to compare the size of two dates startdate and enddate in this page form when submitting a page, and make a judgment.
Is there a date function that can be converted to a type that can compare size regardless of what type date is?
Write with the PHP statement, I will not JS with Ajax, thank you!
------Solution--------------------
PHP Code
1, ' Feb ' = 2, ' Mar ' = 3, ' Apr ' = 4, ' May ' + 5, ' June ' and ' 6 ', ' July ' and 7 ', ' Sept ' + 8, ' Oct ' =& Gt , ' Nov ' +-one, ' Dec ', ' + '; $m = substr ($date, 0, Strpos ($date, '/')); $good = Str_replace ($m, $mon [$m], $date);//Return Time stamp for shaping return strtotime ($good);} $date 1 = "apr/13/2012"; $date 2 = "apr/6/2012";//April 13 is larger than April 16, resulting in Truevar_dump (GetTime ($date 1) > GetTime ($date 2));
------Solution--------------------
C + + code
[User:liangdong time:13:54:44 path:~/php]$ php date.php 2012/7/2[user:liangdong time:13:54:46 Path:~/php]$ cat date.php
------Solution--------------------
PHP code
cat:cat:no such file or directory!--? phpfunction s Tr_to_time ($str _date) {$mon _name = array ("Jan", "Feb", "Mar", "APR", "may", "June", "July", "Sept" "," Nov "," Dec "); $mon _index = range (1, 12); $str _date = Str_replace ($mon _name, $mon _index, $str _date); Return @strtotime ($str _date);} Echo str_to_time ("2012/JULY/2");? -->