PHP: Comparing dates/date strings in PHP

Comparing Date strings in PHP is easy using strtotime function.
The strtotime function returns # of seconds since Jan 1,1970 UTC.

Simple example:
$strtDate = strtotime("2009-10-3");
$endDate = strtotime("2010/11/9");
if($strtDate > $endDate){
 // do something
}
if($strtDate < $endDate){
 /do something
}

No comments:

Post a Comment

Python contextlib for Timing Python code

If you've ever found yourself needing to measure the execution time of specific portions of your Python code, the `contextlib` module o...