Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
User Journal

Journal eno2001's Journal: WHY: The 'date' Command 3

I needed to figure out how to get the 'date' command in Unix to give me yesterday's date. It turns out that it is rather simple, although the initial man page doesn't really provide examples... Here's how you do it:

date -d "1 day ago"

Rather nice actually. So I decided to experiment and see what else I could do with it. It turns out that replacing "day" with week, month and year works too. Cool. So I decided then to try "100 years ago" and that still worked! Nice. So... what about 1000? No dice. What about 500? Bzzzt. After more experimenting, I found that the furthest back I can go is 124 years ago. So that brings me to my main question: why? Is there something significant about 124 years ago? Not to mention that the result of 124 years ago is rather puzzling:

TheCoolestGuyInTheUniverse@TheBeast ~ $ date -d "124 years ago"
Fri Dec 13 15:13:41 LMT 1901

1901+124=2025? Have I found a rift in the fabric of reality? Am I in the Matrix? Is someone going to come and offer me the red/blue pill choice soon? Not to mention the smaller question: WHAT is LMT? And yet another oddity I noticed:

TheCoolestGuyInTheUniverse@TheBeast ~ $ date -d "100 years ago"
Wed Oct 17 11:45:42 CST 1906

Why, if I am in the EDT timezone does 100 years ago display CST? I am aware that daylight savings time is relatively new, but wouldn't EDT hasve just been US-EST before EDT?

Anyone out there "in the know"?

This discussion has been archived. No new comments can be posted.

WHY: The 'date' Command

Comments Filter:
  • Wherein I answer one of my own questions. LMT = Local Mean Time. See the History section of Time Zones on Wikipedia: Gotta Love Wikipedia [wikipedia.org]!
  • The unix timestamp starts at the "Epoch" which is Jan 1, 1970. Any times before that are "negative" in a sense. It stops at 2^31 seconds after the Epoch (32 bit signed, because the time() function can return -1), or Jan 19 2038.

    date should give accurate results between jan 1 1970 and jan 19 2038. Anything outside that range? Not likely.

    Ratboy

Credit ... is the only enduring testimonial to man's confidence in man. -- James Blish

Working...