I have 2 options, the first of which, is that horcruxes do not need to be created at the exact moment you kill a victim. We know from JKR that there is a process and a spell or 2 that need to happen to create a horcrux, and we also know that killing damages the soul, which allows a piece to be broken off.
MA: What is the process? Do you-- Is there a spell? Is there a-- What do you have to do?
JKR: I see it as a series of things you would have to do. So you would
have to perform a spell. But you would also-- I don't even know if I
want to say it out loud, I know that sounds funny. But I did really
think it through. There are two things that I think are too horrible,
actually, to go into detail about.
‘By an act of evil – the supreme act of evil. By committing murder. Killing rips the soul apart. The wizard intent upon creating a Horcrux would use the damage to his advantage: he would encase the torn portion –’
So this process seems somewhat time consuming. We also know a damaged soul can only be repaired through remorse.
Ron: "Isn't there any way of putting yourself back together?"
Hermione: "Yes, but it would be excruciatingly painful."
Harry: "Why? How do you do it?"
Hermione: "Remorse. You've got to really feel what you've done.
There’s a footnote. Apparently the pain of it can destroy you. I can’t
see Voldemort attempting it somehow, can you?"
So given this, we again don't have an exact date that he created the diary, but I would hazard that he created it AFTER he was told he could no longer stay at Hogwarts over the summer, and decided to close the chamber, and frame Hagrid. This to me is the most logical conclusion as the Diary was intended to be used to open the chamber again.
The second option which is a very simple fix to adding memories after the fact.
We know how easy it is for memories to be extracted in Harry Potter, and in fact the memories we see through the diary have striking similar feel to memories viewed through the pensive.
Once before, Harry had found himself somewhere that nobody
could see or hear him. That time, he had fallen through a page in
an enchanted diary, right into somebody else’s memory . . . and
unless he was very much mistaken, something of the sort had happened
again. . . .
This memory is the only one that Tom chooses to show Harry, and it may simply be because it is the only memory added to the Diary in a way which can be shown like this. So creating the Diary immediately after killing Murtle and then added the memory of catching Hagrid after the fact is a simple feat.