Operating System - HP-UX
1827286 Members
3372 Online
109717 Solutions
New Discussion

how to get an earlier date hp ux

 
idi
Occasional Contributor

how to get an earlier date hp ux

hi,
i need to get an earlier date, but do not know how to do.Is there any command for this?
9 REPLIES 9
harry d brown jr
Honored Contributor

Re: how to get an earlier date hp ux

Are you asking for HP-ux 9.04, 10.20, 11.00 ??

Are you asking to set the date of the system back to an earlier date?

Setting the system date back in time can be dangerous, especially if you have time sensitive applications like databases.

live free or die
harry d brown jr
Live Free or Die
Mel Burslan
Honored Contributor

Re: how to get an earlier date hp ux

I could not quite clearly understand your question but it must be one of these two scenarios.

1. you want to change the date of a file to previous date (not very wise if the file is being used by an application dependent on the modification date and time but it can be done). If this is the case, use the "touch" command as follows

touch -t YYMMDDhhmm filename

2. you want to know what day of the week certan number of days ago, or what was the date lets say 129 days ago etc. In which case please use the script of your choice (PERL or Shell) provided by Clay Stephenson of these forums, found here:

Shell Version: http://mirrors.develooper.com/hpux/caljd-2.23.sh

PERL Version: http://mirrors.develooper.com/hpux/caljd-2.2.pl
________________________________
UNIX because I majored in cryptology...
Giacomo TOTTI
Advisor

Re: how to get an earlier date hp ux

HI,
it's the same date command that you have to use.
See the man pages for format

Giacomo
harry d brown jr
Honored Contributor

Re: how to get an earlier date hp ux


If you want to adjust the system date, the format is:

date MMDDhhmmCCYY
where MM=two digit MONTH
DD=two digit DAY
hh=two digit MILITARY time (1pm = 13)
mm=two digit minute
CC=two digit CENTURY (20 or possibly 19)
YY=two digit YEAR

So to set the date back to February 28th, 2005 at 1:18 PM, do this:

date 022813182005

But again, I stress that this can be dangerous! Going back past Y2K (2000) can also cause issues. A reboot might me necessary in either case.

live free or die
harry d brown jr
Live Free or Die
Venkatesan_5
Frequent Advisor

Re: how to get an earlier date hp ux

Hi,
There are two conditions
1. If you want to adjust or change the system date, the format is:

date MMDDhhmmCCYY
where MM=two digit MONTH
DD=two digit DAY
hh=two digit MILITARY time (1pm = 13)
mm=two digit minute
CC=two digit CENTURY (20 or possibly 19)
YY=two digit YEAR

2. If you want to know the previous year or month ...then the command is "cal"

# cal 7 1999

this will show you the monthly view of July 1999.

syntax is : # cal

I think this should solve your purpose...


regds

Venkatesan.
Muthukumar_5
Honored Contributor

Re: how to get an earlier date hp ux

you can use cal command for this also.

cal to view previous date with day informations.

hth.
Easy to suggest when don't know about the problem!
idi
Occasional Contributor

Re: how to get an earlier date hp ux

i mean, how i know 15 day before today,
for ex:

today system date is: Fri Jan 8 08:34:34 EETDST 2005

and when i give '15 day defore' for input,
i want to see

Dec 24 2004 for an output.

So How?

Roland Piette
Regular Advisor

Re: how to get an earlier date hp ux

Hi,

You can write a little programme in C with time function.

See man page with the command "man 2 time".

Roland
A. Clay Stephenson
Acclaimed Contributor

Re: how to get an earlier date hp ux

Use the attached script, caljd.sh.

Then it's very easy:

DT=$(caljd.sh $(caljd.sh -p 15))
echo "Date 15 days ago was ${DT}"

Invoke as caljd.sh -u for full usage and many examples.
If it ain't broke, I can fix that.