We actually had a thread like this a while back. Basically, expiry dates guarantee that a medication is at full potency AT LEAST until the expiry date. This does not necessarily mean that the medication is not effective past this date, but that the manufacturer is no longer guaranteeing potency. There is generally no harm in taking medications, other than there is a chance they may not provide the full effect. Indeed, provided that a medication is stored properly, it may be good even years past its expiry date. I recall reading that medication like Tylenol may be good for 5 years past the date. I have an older prescription of flagyl from 2013 that I'm storing in a cool dark cupboard. Flagyl is also a medication that may be good for several years.
So no need to throw it out. You can take it and if you notice it's not as effective as usual, it may have lost some potency. But generally, it should be okay. That said, if you have a prescription for a potentially life or death condition, I wouldn't chance expired medication, but certainly imodium is something I wouldn't hesitate to take, even if it was a few years old (again, provided it was stored appropriately).
Here is a link to an article that may be helpful. https://www.drugs.com/article/...xpiration-dates.html