Hard, not hardly, is the adverb of the adjective hard. Hardly must not be used except in the sense of scarcely. Hardly earned and hard-earned have quite different meanings.
Hardly, like scarcely, is followed by when not by than, in such a sentence as "I had hardly begun when I was interrupted".
Than sometimes creeps in from a false analogy with "I had no sooner begun than I was interrupted".