Kernel keeps the number of seconds about uptime. The numbers can be found in /proc/uptime. In kernel source uptime variable is declared as long. (include/linux/kernel.h) After cca. 500 days the counter resets because of overflow. Uptime in seconds needs larger number type.
This is by design; uptime has to be atomically updated. Changing this gets proposed over and over on linux-kernel, and is repeatedly rejected for the same reason.