How long can Arduino Uno work without switching it off?

kuhntucker:
If you use the millis() or micros() functions you will need to consider that they rollover and start again at 0 periodically. The millis() function is good for about 50 days before a rollover, the micros() function about 70 minutes.

The roll over will be no problem if you follow the techniques in the Blink without delay example.

our Sun will be exploding in the future

I think exploding is a bit too dramatic, it is more of a slow expansion that will see the Earth being swallowed up. It happens over many Melania so it won't be sudden, still a bit catastrophic mind you.