cancel
Showing results for 
Search instead for 
Did you mean: 

How to get date 2 days ago

SOLVED
Go to solution
Victor Semaska_3
Esteemed Contributor

How to get date 2 days ago

Greetings,

I'm primarily Tru64 UNIX but I'm slowly moving into the Linux world. I'm porting a ksh script of mine to Linux which gets the date 2 days ago. On Tru64 UNIX this command works:

# (export TZ; TZ=UTC+48; date '+%Y%m%d')
20070603

On RedHat Linux it returns yesterday's date:
# (export TZ; TZ=UTC+48; date '+%Y%m%d')
20070604

So, what am I doing wrong here.

Thanks,
Vic
There are 10 kinds of people, one that understands binary and one that doesn't.
2 REPLIES
Ivan Ferreira
Honored Contributor
Solution

Re: How to get date 2 days ago

In linux, you can use:


date --date "2 days ago"

Cool isn't it?
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Victor Semaska_3
Esteemed Contributor

Re: How to get date 2 days ago

Thanks Ivan,

1) Somehow I knew you would have the answer.
2) I can't believe it's that simple.

Vic
There are 10 kinds of people, one that understands binary and one that doesn't.