Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sco unix datetime

Status
Not open for further replies.

jaseuc

MIS
Feb 7, 2002
2
US
Hi:

I am writinig a script and I need to get the system date in the same format stat function returns it (# of seconds from Jan 01, 1970 GMT 00:00).

Does SCO Unix 5.0X has any way (date ?) to retrieve current datetime in that same format, so I could get the interval between those two easily?

Juan A Seuc
 
Hi:

There's no easy way in SCO:

1) Get the GNU versions of date or awk from gnu.org.

2) Use Perl, TCL, "C", or some other programming tool. I have a Perl solution, and I'll post it here if you like.

Regards,


Ed
 
The following command (as a single line) will return what you want.

Code:
date -u '+%Y %j %H %M %S' | awk '{printf("%d\n",((((int($1/4)*4)-1972)/4*126230400)+63158400+(($1-(int($1/4)*4))*31536000))+(($2-1)*86400)+($3*3600)+($4*60)+$5);}'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top