Imodium should be taken before you eat, 30 to 60 minutes. Or if you are needing it regularly, then you can just take it throughout the day, up to 8 tablets, which might mean a maximum 2 in the morning, 2 at lunch, 2 at dinner hour and 2 before bed. You can adjust the timing up or down as you need more/less. If that's the case, then you don't really need to worry about timing it precisely with your meals, just stick to your usual schedule.
My surgeon recommended taking the metamucil before bed.