Dogs and their masters are sometimes separated for long periods of time due to illness, extended vacation or overseas deployment. When the master returns after a long absence the dog does remember her and often displays happiness and affection as a result of the reunion. The cause for such a reaction is the dog's ability to recognize his master's face in ways that other animals may not be able to.
Scientists at Italy's University of Padua discovered that dogs use facial recognition to identify humans. The 2013 study used testing to show that dogs do not use just their sense of smell, hearing and the analysis of physical characteristics to find their master. Instead they look at faces to see who a person is, if they are familiar or unfamiliar and if they are the master they know and love. The dogs who were tested also had to choose between two humans with covered faces. They did not react the same way and displayed some disinterest toward their owners.
Dogs may not be able to tell time or count the days that you are gone, but they are able to register periods of time spent alone either due to the lack of routine or your presence itself. Dogs do not have episodic memory, or the ability to know how and when you left. Instead they use a system of clues. Your dog is dependent on you for things like food, walks and general companionship. He knows you must be there for these things to happen and may look for clues as to when they will occur.
Although dogs do not tell time the way humans do, they are able to predict occurrences perhaps based on internal indicators. For example, if you come home every day at 6 p.m. to your waiting puppy, he will begin to expect you home at that time and will predict your arrival by how hungry or sleepy or bored he is. Over time this skill can become quite accurate and in the case of your extended absence may be the main way your dog determines how long you've been gone.
Given their concept of time, ability to make predictions and identify human faces, it is clear that dogs who've been apart from their masters for long absences are able to recognize them and react accordingly. The news is filled with stories of soldiers returning from battle to an overjoyed greeting at the airport not only from family or friends, but from their dogs. If you are not around, your dog knows things have changed and a certain level of comfort is lost. Your return also signifies a return to this comfort zone. The fact that dogs see the difference in faces makes it clear that dogs who have been separated from their masters for long periods can and do recognize them when they are finally reunited.