glenelkins Posted July 6, 2006 Share Posted July 6, 2006 HiThe following lines of code generate 2 dates. Now i want to compare if($weddingdate <= $groupdate) but this does not do anything. How would I compare the two?[code]$temp_wd = explode("-",$_POST['date']);$weddingdate = date("Y-m-d",mktime(0,0,0,$temp_wd[1],$temp_wd[0],$temp_wd[2]));$temp_gd = explode("-",$_POST['groupdate']);$groupdate = date("Y-m-d",mktime(0,0,0,$temp_gd[1],$temp_gd[0],$temp_gd[2]));[/code]cheersg Quote Link to comment Share on other sites More sharing options...
.josh Posted July 6, 2006 Share Posted July 6, 2006 the date function creates a string. you can't compare if one string is less than or equal to another string. For example, what do you expect php to do if you do this? if ('apples' <= 'oranges') { .. }you need to do like this:[code]$temp_wd = explode("-",$_POST['date']);$wed = mktime(0,0,0,$temp_wd[1],$temp_wd[0],$temp_wd[2]);$weddingdate = date("Y-m-d", $wed); $temp_gd = explode("-",$_POST['groupdate']);$group = mktime(0,0,0,$temp_gd[1],$temp_gd[0],$temp_gd[2]);$groupdate = date("Y-m-d",$group);if ($wed <= $group) { .. }[/code]the mktime() function creates the unix timestamp which is an integer value, which CAN be compared properly. Quote Link to comment Share on other sites More sharing options...
glenelkins Posted July 6, 2006 Author Share Posted July 6, 2006 ah yes, im a dumb ass lol.cheers Crayon Quote Link to comment 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.