es war einmal

How is es war eimal used in German to give the same sense as "once upon a time"? "Once upon a time there was a man ..." Because the phrase means "it was once," right? I'm kind of confused how it works. :-\