Pivoting a cube from its end

Is there a way to pivot a cube from a place other than the center? I want to make a simple animated box with legs, so all I want to have to do is pivot some box’s from their top, how could I achieive this?

You can create an empty object and drop the cube into that, then offset the cube inside that empty object. Pivot on the parent object.