diameter0101 Posted January 15, 2016 Share Posted January 15, 2016 (edited) Compare 2 dates: $date1 = strtotime("+6 months"); (6 months from now on) $date2 = strtotime("02/2017"); (in format month/YEAR) I need to compare if $date2 is larger than $date1 ... if($date2 >= $date1) { } Edited January 15, 2016 by diameter0101 Quote Link to comment https://forums.phpfreaks.com/topic/300377-php-compare-dates/ Share on other sites More sharing options...
Muddy_Funster Posted January 15, 2016 Share Posted January 15, 2016 You also need to work out how to ask a question What's the issue you are having? what's your actual code (not the pseudo you have posted)? What's the expected result and? what's the actual result? What have you tried thus-far? Do you need to check if date2 is "greater than" or do you need to check if date2 is "greater than or equal to" (because you claim one and show the other)? Oh, and welcome to the PHPFreaks Forums Quote Link to comment https://forums.phpfreaks.com/topic/300377-php-compare-dates/#findComment-1529761 Share on other sites More sharing options...
Barand Posted January 15, 2016 Share Posted January 15, 2016 You need "2017/02" to convert it to a valid timestamp Quote Link to comment https://forums.phpfreaks.com/topic/300377-php-compare-dates/#findComment-1529762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.