Operating System - HP-UX
1753794 Members
7071 Online
108799 Solutions
New Discussion юеВ

converting seconds since 1980 to current date

 
SOLVED
Go to solution
carolyn sorensen
New Member

converting seconds since 1980 to current date

Hi, I have a database with dates in "HP/Apollo seconds since 1980." How can I convert this (under Windows) to date/time, with leap years, days, seconds etc. considered?

Thanks MUCH in advance for help.

Carolyn
3 REPLIES 3
Hein van den Heuvel
Honored Contributor
Solution

Re: converting seconds since 1980 to current date

Perl can readily solve this on Windows and Unix alike. Just figure out 'since 1980' once, and then add that as base to any Apollo date.

Base:

$ perl -e 'use Time::Local; print timelocal(0,0,0,1,0,1980) '
315550800

Use:

$ perl -e 'print scalar localtime(315550800 + 3650)'
Tue Jan 1 01:00:50 1980

$ perl -e 'print scalar localtime(315550800 + 403650)'
Sat Jan 5 16:07:30 1980

Check out the perl documenation to see how to get the components of such new time:

http://perldoc.perl.org/functions/localtime.html


Hope this helps some,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting

Steven E. Protter
Exalted Contributor

Re: converting seconds since 1980 to current date

Shalom,

Great scripts for figuring things like this out.

http://hpux.ws/merijn/caljd-2.25.sh

http://hpux.ws/merijn/caljd-2.2.pl

I use these as production scripts. Written by A. Clay Stephenson

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
carolyn sorensen
New Member

Re: converting seconds since 1980 to current date

Thanks guys! I needed the hint about Julian dates. I got the date for 1/1/1980 using the script cal_jdate(). When added to our 'date' value & converted back to gregorian, it works beautifully. (Poor documentation on top of all else -- the doc says seconds since 1980, but its clearly not.)

Thanks again!
Carolyn