Get Yesterday's Date in Solaris

Get Yesterday's date in solaris

Try this below thing. It should work

YESTERDAY=`TZ=GMT+24 date +%Y%m%d`; echo $YESTERDAY

In a unix shell, how to get yesterday's date into a variable?

If you have Perl available (and your date doesn't have nice features like yesterday), you can use:

pax> date
Thu Aug 18 19:29:49 XYZ 2010

pax> dt=$(perl -e 'use POSIX;print strftime "%d/%m/%Y%",localtime time-86400;')

pax> echo $dt
17/08/2010

How to get yesterday date in Unix

Ksh's printf supports datetime manipulation:

# echo ${.sh.version}
Version AJM 93u+ 2012-08-01
# printf '%(%Y-%m-%d)T\n' today
2015-09-03
# printf '%(%Y-%m-%d)T\n' yesterday
2015-09-02
# printf '%(%Y-%m-%d)T\n' '5 days ago'
2015-08-29
#

Get yesterday's date in bash on Linux, DST-safe

I think this should work, irrespective of how often and when you run it ...

date -d "yesterday 13:00" '+%Y-%m-%d'

getting a previous date in bash/unix

Several solutions suggested here assume GNU coreutils being present on the system. The following should work on Solaris:

TZ=GMT+24 date +’%Y/%m/%d’


Related Topics



Leave a reply



Submit