In the accepted text, based on in the Second Quarto and First Folio editions, the gravedigger reveals this in his conversation with Hamlet: (5.1.56-100)
Hamlet:
How long hast thou been a grave-maker?
Gravedigger:
I came tot that day that our last king Hamlet overcame Fortinbras
It was that very day that young Hamlet was born
I have been sexton here man and boy thirty years
.this skull hat lien you ithearth three-and-twenty years
.this same skull, sir, was, sir, Yoricks skull
Hamlet:
He hath borne me on his back a thousand times
those lips that I have kissed I know not how oft
.
In the First Quarto edition, though, "I have been sexton here man and boy thirty years" is missing, and the gravedigger says instead of 23 years, "heres a scull hath been here this dozen year." : (Q1: 3361)