The 31-year-old, who joined from Marseille in July, made just two appearances for the Hammers before picking up a thigh injury.
He told France Football: "In my mind I am fine, but physically I am not so well. I picked up a serious right thigh strain about a fortnight ago. The examinations revealed quite a big hematoma.
"The club doctor stated I will need two months to recover, but I hope it will be a little less. You just have to put up with it, get good treatment, and let it heal to avoid relapse. But after starting for a new club it is quite annoying."
Diarra has also played in the Premier League for Liverpool.