Board Thread:Questions and Answers/@comment-27876276-20161207033444/@comment-27701762-20161207035738

So Sans does not actually have a direct connection to the timelines themselves. Instead, what he has is basically data that say that some entity is messing with the timeline, which he surmises to be the protagonist. From that data, he is able to essentially reason through a few things, such as when people are time traveling based on how they react to certain events (hence his reaction to the protagonist's facial expressions at various points in the story). In addition he presumably, like the other characters, has a faint memory that lingers from other timelines, which is akin to experiencing ''deja vu. ''Sans is special, though, insofar as he knows that faint memory is not just a weird coincidence, but a side effect of someone messing with the timeline.

In order for there to be that sort of lingering memory of a different timeline, the character in question needs to have been present for some event on the timeline. For example, when Toriel guesses whether the protagonist prefers butterscotch or cinnamon. So if Sans had wanted to go to the Surface before the anomaly begins messing with the timeline, then there would be no memory for him to have, as there is only one timeline to speak of.

Now, those are sort of the basic facts. Given what his dialogue suggests, his desire to go to the Surface slowly ebbed away as he began to understand that something was messing with the timelines. So in a sense, yes, he was aware of other timelines at that point in his past, but only at a very minor level, and as he gained more awareness he became less interested in trying to return to the Surface. Moreover, given that the protagonist was not the only entity messing with the timeline, but Flowey had control before then, and it is strongly suggested that the previous children also had at least some ability to save and load, there is a high likelihood that Sans would have at some point been hit with that feeling of deja vu and thus would have "seen" a past timeline. Though again, that feeling of deja vu in and of itself is no different from Toriel accurately guessing whether the protagonist prefers butterscotch or cinnamon.