2

I am working on 32 bit linux and i understand 2038 problem https://en.wikipedia.org/wiki/Year_2038_problem

Anyhow , when i try to use date command to set time beyond 03:14:07 UTC on 19 January 2038 and when my system's time zone is set to UTC it works as expected and time_t overflows only after 03:14:07 UTC on 19 January 2038.

But when i keep my time zone to JST-9 , i get weird results even before i set the time to beyong 19th jan 2038 .

see below console outputs

root@X:/# date -s "2038-01-11 03:14:00"
Mon Jan 11 03:14:00 JST 2038
root@X:/# date -s "2038-01-12 03:14:00"
Tue Jan 12 03:14:00 JST 2038
root@X:/# date -s "2038-01-13 03:14:00"
Tue Jan 12 09:14:00 JST 2038
root@X:/# date -s "2038-01-14 03:14:00"
Wed Jan 13 09:14:00 JST 2038
root@X:/# date -s "2038-01-15 03:14:00"
Thu Jan 14 09:14:00 JST 2038
root@X:/# date -s "2038-01-17 03:14:00"
Sat Jan 16 09:14:00 JST 2038

If you see i can set time correctly only till 2038-01-12 03:14:00 and beyond that ie from 2038-01-13 03:14:00, the time in JST is always set to 18 hours earlier .

root@:/# date -s "2038-01-13 03:14:00"
Tue Jan 12 09:14:00 JST 2038

Why is that, any ideas. Anyhow, i am running on kernel 3.18.36 on 32 bit embedded board .

| improve this question | | | | |
  • You are experimenting with a vendor specific extension (-s) that could be buggy. So what exactly is your intention with these tests? – schily Jan 10 at 8:22
  • isn't from man page of date command says "-s, --set=STRING set time described by STRING" anyways, intention is simple to see how system will behave when we close to 2038 .Offcource this means to see the self life of the product which we build on 32 bit systems. – sroy Jan 10 at 8:47
  • This is a non-standard usage that is specific to your vendor. Also note that you of course must not overflow the internal variables. I recommend to use date -u mmddHHMM[cc]yy] which is the official way to use and -u grants no extra overflow potential than the one you already have with 32 bits. – schily Jan 10 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.