The sentiment expressed by these words first appeared in
Christopher North's 1829 work
Noctes Ambrosianae.
The actual words used by Christopher North were 'His Majesty's dominions, on which the sun never sets' (as these words were written in 1829, the "Majesty" in question would have been
King George IV).
The meaning of the words is, of course, quite clear - that the British Empire spanned the entire globe with the result that the sun was always up in some part of the Empire.
The "self-evident truth" of the sentiment in 1829 was soon expressed in the less formal "The sun never sets on the British Empire" form, a sentence and a sentiment which certainly became a foundational part of the British psyche during the coming reign of Queen Victoria.
From a historical perspective, the words were true from roughly the foundation of the East India Company in 1600 through to the end of the Second World War.
The exact dates at either end of the range are certainly open to debate.
For example, did the British Empire come to an end with the founding of the British Commonwealth of Nations in 1931 or with the departure of the British from India and the partition of India into India and Pakistan in 1947?
In truth, the British Empire did not simply come into being one day and cease to exist on some other day so the exact dates are not particularily relevant.
The fact remains that the British Empire did span the globe for a truly impressive period of roughly 350 years.