Mailinglist Archive: opensuse (2912 mails)

< Previous Next >
'date' question (wanna find yestreday date)
  • From: Rhugga <rhugga@xxxxxxxxx>
  • Date: Tue, 8 Feb 2005 06:55:00 -0800 (PST)
  • Message-id: <20050208145501.92316.qmail@xxxxxxxxxxxxxxxxxxxxxxx>

Not sure if I badly need sleep or what, but I can't remember how I used to do this back when.

>From a bash script I want to determine yesterday's date. I don't want a cludge of if statements to
account for months with 30 days vs 31, leap year, and etc....

With C or Perl I would normally take the number of seconds since epoch and subtract 86400, then
supply this integer as an argument to localtime (or whatever) and it then glean the corresponding
date string. (per whatever your desired formatting is)

I cannot seem to find a utility that will allow me to provide the number of seconds and received a
date string in return. I know I have done this numerous times in the past but my scripting skills
have grown rusty... I was almost positive /bin/date would do this in the past but currently trying
the version shipped with SLES 9 and don't see any options that can help me.

Once again, I need to do this in bash, not perl or C.

Thx,
cc

< Previous Next >
Follow Ups