Posted By

mladoux on 09/21/10


Tagged

php date compare utility


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jatubio


past_date


 / Published in: PHP
 

URL: http://mark.haktstudios.com/

A simple utility function to determine if today\\'s date is newer than then a given date. Good for checking expiration dates on data.

  1. /**
  2.  * past_date($date)
  3.  *
  4.  * @param string $date - compares $date to $now to see if the date has passed.
  5.  * @return boolean - returns true if provided $date is newer than $now
  6.  * or false if $date is equal older than $now.
  7.  */
  8.  
  9. function past_date($date)
  10. {
  11. // prepare working variables
  12. $date = strtotime($date);
  13. $now = strtotime(date('Y-m-d'));
  14.  
  15. // evaluate.
  16. if( $date < $now ) return true;
  17. else return false;
  18. }

Report this snippet  

You need to login to post a comment.