Return to BSD News archive
Xref: sserve comp.unix.bsd:14678 comp.unix.misc:13616 comp.unix.programmer:19474 comp.unix.questions:54068 Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!tulane!darwin.sura.net!news.sesqui.net!newsfeed.rice.edu!cs.utexas.edu!not-for-mail From: pzuge@worf.uwsp.edu (Peter Zuge) Newsgroups: comp.unix.bsd,comp.unix.misc,comp.unix.programmer,comp.unix.questions Subject: Q: How can I get yesterday's date? --> ANSWER Date: 16 Aug 1994 17:09:19 -0500 Organization: UTexas Mail-to-News Gateway Lines: 32 Sender: nobody@cs.utexas.edu Message-ID: <Pine.3.89.9408161604.A21469-0100000@worf.uwsp.edu> Reply-To: Peter Zuge <pzuge@worf.uwsp.edu> NNTP-Posting-Host: news.cs.utexas.edu Thanks to all those who responded. There seem to be many ways to get yesterday's date: 1) create a c program ( with ctime() ) 2) YESTERDAY=`TZ=PST32PDT date "+yesterday was %m-%d"` 3) export TZ=GMT+24 But the way I chose was: # First: get the current date of year in seconds # Second: ( no pun intended ) Subtract one day from the amount of seconds # Third: Convert seconds back into date format set seconds=`date +%s set yestrsec=`expr $seconds - 86400` date -r $yestrsec ( Or whatever time format you want ) **Answer from Stefan Grefen. <<<< o(0-0)o ------------------ooO-(_)-Ooo------------ Peter A. Zuge Gopher Administrator U of Wisconsin, Stevens Point Information Technology ----------------------------------------- Gopher: gopher.uwsp.edu e-mail: pzuge@worf.uwsp.edu