string - Compare current date with a date in d/mm/yyyy format in PHP -


what best way check if given date - string d/mm/yyyy past? when used strtotime(), didn't work well, because of non-american notation. of course might deal dates strings , compare substrings, there has better way.

if((strtotime('now')-strtotime($date)) > 86400) echo $date; 

dates in m/d/y or d-m-y formats disambiguated looking @ separator between various components: if separator slash (/), american m/d/y assumed; whereas if separator dash (-) or dot (.), european d-m-y format assumed.

strtotime() manual

so simple str_replace('/', '-', $date) should trick.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -