To avoid the Y2038 problem once and for all, how many bits wide should the time counter data type be?
We imagine "life as we know it" being able to exist and survive in this universe until protons decay, which will occur somewhere between 10^36 and 10^200 years from now, depending on the mechanism of proton decay. (We assume protons do decay, or else the numbers become too extreme.) On the other extreme, let the counter count Planck time intervals, or actually intervals of 2^-144 seconds, approximating Planck time to the nearest power of 2. In total, this requires a counter 835 bits wide, including sign.
The current counter value can be obtained by multiplying the current Unix time by 2^144, yielding 32424036371789043421224367124922038042726664415215616 at the time of this writing. Slightly problematically, we would like a time counter synchronized with TAI, not UTC as Unix time is, because this counter will keep counting long after the earth and sun stop existing. (UTC keeps synchronized with the day-night cycle by adding leap seconds.)
Amusingly, we can count down to when this counter will overflow, so it becomes a very rough estimate of time remaining until the end of the universe, for life as we know it. The countdown value is 2^834-t = 114555615673899844817675135734699353962886956688682610117765798809244256021411616637381137063298513501717438036875998880297587443028293506801780104166258318482051497231916848409067205045915915104980127608890609200860300990059825412423392421761481965568 Planck time units at the time of this writing.
Life not as we know it, perhaps existing as pure energy after proton decay, will have to deal with transitioning to a wider time counter or establishing a new epoch.