|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
Yesterday's date
Anybody know how too get yesterdays date ? Perhaps by manipulating the date command ?
|
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Using Solaris.. could not get it too work. Anyone know ?
|
|
#4
|
|||
|
|||
|
>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. |
|
#5
|
|||
|
|||
|
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). |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Yesterday's date |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|