soycharliente Posted June 11, 2007 Share Posted June 11, 2007 In my db table, my date field uses YYYY-MM-DD, but if you compared 2007-6-1 to 2007-06-01 you would get FALSE. What can I do about this? I'm passing days using the GET method and then populating an events div with events from a db table that match the D M and Y. I would like it to work for both numbers with and without leading zeros. Quote Link to comment https://forums.phpfreaks.com/topic/55028-solved-comparing-dates/ Share on other sites More sharing options...
AndyB Posted June 11, 2007 Share Posted June 11, 2007 Whether they're passed with GET or POST makes no difference. You'll need to process them in some way to get a yyyy-mm-dd string for comparison purposes unless you use a user input method that only allows correctly formed dates, i.e. a dropdown. Meantime, the below should suffice to convert inputs retrieved from a passed array. $iso_date = date("Y-m-d", strtotime(0,0,0,$m,$d,$y)); Quote Link to comment https://forums.phpfreaks.com/topic/55028-solved-comparing-dates/#findComment-272023 Share on other sites More sharing options...
soycharliente Posted June 11, 2007 Author Share Posted June 11, 2007 I have a calendar with each day being a link that just passes what D M Y it corresponds to into the URL. SO when I process the page, I should take the D M Y from the GET array and use the date() function and mktime() to get the format that I need? Quote Link to comment https://forums.phpfreaks.com/topic/55028-solved-comparing-dates/#findComment-272025 Share on other sites More sharing options...
AndyB Posted June 11, 2007 Share Posted June 11, 2007 Yup. mktime not strtotime (got up too early today, obviously) Quote Link to comment https://forums.phpfreaks.com/topic/55028-solved-comparing-dates/#findComment-272027 Share on other sites More sharing options...
soycharliente Posted June 11, 2007 Author Share Posted June 11, 2007 ROFL. I didn't even notice you said strtotime(). I read mktime(). Quote Link to comment https://forums.phpfreaks.com/topic/55028-solved-comparing-dates/#findComment-272031 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.