1833346 Members
4361 Online
110051 Solutions
New Discussion

get tommorow date

 
SOLVED
Go to solution
Sir T S S
Advisor

get tommorow date

how to get tommorow date and I think gnu date should had this but HP dun provide this facility.

Any scripts that can produce output like yyyymmdd.?
4 REPLIES 4
Peter Godron
Honored Contributor

Re: get tommorow date

Peter Godron
Honored Contributor

Re: get tommorow date

Or as a perl version:
#!/usr/bin/sh
TOMORROW=$(perl -e '($mday,$mon,$year) = (localtime(time() + 86400)) [3,4,5]; printf("%04d%02d%02d\n",$year +1900,$mon + 1,$mday)')
echo "Tomorrow is ${TOMORROW}"
Regards
Laurent Menase
Honored Contributor

Re: get tommorow date

#include
main(c,v)
int c;char**v;
{ time_t t;char b[256];
time(&t);
t+=60*60*24*atoi(v[1]);
strftime(b,255,"%m/%d/%Y",localtime(&t));
puts(b);
}
/* cc t.c -o t
usage: t [numberofdays]*/

$ ./t 1
04/01/2005
$ ./t -89
01/01/2005
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: get tommorow date

TOMORROW=$(caljd.sh -y -s $(caljd.sh -n 1))
echo "Tomorrow is ${TOMORROW}"

By changing -n 1 to -n days you can get any future date and similarly -p days will work for any number of days in the past. It's also very easy to make it automatically skip weekends and/or holidays. Invoke as caljd.sh -u for full usage.
If it ain't broke, I can fix that.