Jump to content

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/55028-solved-comparing-dates/
Share on other sites

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));

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.