Get yesterday date in Unix - KSH script -


the below command used getting yerterdays date in unix ksh on hp ux

date_stamp=`tz=cst+24 date +%m/%d/%y`  

can let me know "cst + 24 date " in above command do?

that command sets timezone cst+24 , returns date in timezone.

if looking command find out yesterday's date, better of using tz trick esp. if in timezone observes dst.

use perl 1 liner instead.

#this takes local time , substracts day(24*60*60 seconds) , formats time. echo `perl -e 'use posix; print strftime "%m/%d/%y%", localtime time-86400;'`  

just guess on command - since yesterday @ cst+24 timezone command returns yesterday's date , if use cst-24, retunrs tomorrow's date since date translates tomorrows date @ cst-24 timezone.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -