We can give thanks, even when times are hard. It's one thing to give thanks when things are going well. But we can also give thanks when things are not going well.
Of the many beautiful psalms David wrote, one of my favorites is Psalm 63: "Because Your lovingkindness is better than life, my lips shall praise You. Thus I will bless You while I live; I will lift up my hands in Your name" (verses 3–4).
We may think David wrote this psalm while he was kicking back on a beautiful sunny day. But that wasn't the case. David actually wrote this psalm in exile, while he was running from his son Absalom, who was trying to take his throne. Not only that, but David was an elderly man by this time. He was in anguish and personal pain.
We can praise the Lord in good times, and we can praise the Lord in bad times. And by the way, I don't think we will fully understand what is good or bad this side of Heaven anyway. When we're younger we think certain things are good and other things are bad. Success? Always good. Hardship? Always bad. That's how we think.
But then, after we've lived for a while, we can look back and say, "Actually, success can be bad for some. And actually, hardship can be good for others." We begin to look at things differently. Sometimes the things we thought were really good turn out to be bad. And the things that we thought were bad turn out to be really good.
The Lord can take all things, bad or good, and according to Romans 8:28, work them "together for good to those who love God, to those who are the called according to His purpose."