1827044 Members
3385 Online
109713 Solutions
New Discussion

subtract Date

 
HartfordBala1973
Occasional Advisor

subtract Date

Hi,
Iam working in HP-UX 11i env, please help me how to subtract current date minus 2 hours.
I want to display the time before 2 hours.

Thanks & Regards
Balaji
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: subtract Date

Hi:

Use perl;

# perl -le 'print scalar localtime(time-(2*60*60))'

This subtracts 2-hours (in seconds) from the current date and time.

Regards!

...JRF...
Arturo Galbiati
Esteemed Contributor

Re: subtract Date

Hi,
you can look for caljd script in the forum.
HTH,
Art
Laurent Menase
Honored Contributor

Re: subtract Date

#include
main()
{
time_t x;
char buf[512];
time(&x);
x=x-2*3600;
strftime(buf,511,"%H:%M:%S",localtime(&x));
printf(buf);
}

in shell, but without taking DST in account:
typeset -i x
x=$(date +%H)
x=x+98
heure=${x#1}$(date +:%M:%S)