SPOILER WARNING FOR PEOPLE WHO HAVEN'T SEEN THE MOVIE: DON'T READ ON

Ok, so I'm unbelievably slow, and I just watched "The Shining" for the first time last night, and I just didn't get the bit at the end. So at first i was Ok with the storyline. Basically he started to go mental at the and and wanted to kill his own family right? Because "they need a good talking to...perhaps a bit more".

But the thing that I don't understand is how the waiter guy, Delbert Grady who supposedly was the one who killed his own family before commiting suicide, is in the bathroom with Jack, insisting that he was never a caretaker at the hotel and he never killed his family. Then he goes on to say that Jack has always been the caretaker there.

Basically I thought that all the crazy stuff happening to jack (the meeting with Delbert Grady for example) was in his mind as he started to go insane, but then at the end it zooms in on that staff photo of the hotel that is labeled "Overlook Hotel, 1930" (or was it 1920?)

I just don't understand how he was at the hotel in 1930, when he arrived at the hotel in the 80s. I know there's supposed to be a big twist, but I just didn't get it.