IBM developerWorks
           UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old September 19th, 2003, 03:16 AM
mccrack_2003 mccrack_2003 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: ZA
Posts: 2 mccrack_2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yesterday's date

Anybody know how too get yesterdays date ? Perhaps by manipulating the date command ?

Reply With Quote
  #2  
Old September 19th, 2003, 05:06 PM
Prime Mover Prime Mover is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Jersey
Posts: 64 Prime Mover User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Yep, date manipulation - the command:

date -v-1d

will give you the date output reading of one day previous on a FreeBSD system. Probably similar on other Unices, man date.

-Gary
__________________
Trying to change its program
Trying to change the mode...crack the code
Images conflicting into data overload

Reply With Quote
  #3  
Old September 22nd, 2003, 05:15 AM
mccrack_2003 mccrack_2003 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: ZA
Posts: 2 mccrack_2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Using Solaris.. could not get it too work. Anyone know ?

Reply With Quote
  #4  
Old September 22nd, 2003, 08:05 AM
Kung Foo Master Kung Foo Master is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 68 Kung Foo Master User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
>Using Solaris.. could not get it too work. Anyone know ?
% man date

Read up on the commands that your date program supports. There should be an option for adjustment of varying degrees.

Reply With Quote
  #5  
Old September 22nd, 2003, 08:35 AM
druuna druuna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 137 druuna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 37 sec
Reputation Power: 0
Don't know if the TZ (Timezone variable) is set in your environment. If so something like this will do the trick (I also don't have the -v option, or similar alternative, in date).
Code:
#!/usr/bin/ksh
# Name       : pdate
# Purpose    : Reports the date 'shift' hours from now, formatting is allowed

typeset -i X

if (( $# < 1 ))
then
        print -u2 "Usage: $0 shift [ + format ]"
        print -u2 "Reports the date 'shift' hours from now. Format as in date."
        exit 0
fi

X=$1
F=$2
TZ=`echo $TZ | sed -e "s/MET-1/MET$((-1-X))/" -e "s/DST-2/DST$((-2-X))/"`

if [[ -z $F ]]
then
        date
else
        date "$F"
fi


You might need to change $TZ to your $Timezone variable (if one excists that is).

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Yesterday's date


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway