Thanks for posting your query
From your description you are likely suffering from constipation
which could be due to a number of reasons such as reduced intestinal peristaltic movements (due to unknown cause), indigestion, intestinal infection, poor diet etc. In any case, try drinking much water (can be warmed slightly), eat a lot of fruits especially paw paw and vegetables, avoid dry food especially if uncooked. Get your stool tested for intestinal worms.
The hard stool has lead to anal fissure
or possibly internal hemorrhoids
. You will require checking with your doctor. It is possible that you are suffering from the effects of the anesthesia used for your knee replacement
surgery. In that case, symptomatic management and prevention of local anal complications such as abscess or wound infection
by use of stool softeners or laxatives and antibiotics in prophylactic doses (avoid the fissures being affected by the microorganisms found in your stool).
Best regards and wish you the best