[Omaha.pm] converting dates

Daniel Linder dan at linder.org
Thu Sep 9 14:52:15 CDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


<quote who="Terry">
> I want to be able to take an number which is the # of days since
> 1/1/70 and convert it into a user-friendly date.
>
> Like 12594 for example.
>
> Date::Manip doesn't seem to have much love in this area....have any other
> ideas?

Since the "epoc" is just number of seconds since midnight 1/1/1970, how
about this:
$datenum = 12594;
$datenum *= (24*60*60);
$date = &ParseDateString("epoch $datenum");
printf "$date\n";

Returns this output:
2004062419:00:00

(i.e. 2004 06 24 @ 19:00:00 ?)

So, is this close?  I assume that leap years/seconds make up for the time
being off by 5 hours (19:00 vs. 00:00) You could then run $date through
the Date::Manip routines to clean it up further.

I guess you could toy around with this routine going the other way:
$secs = Date_SecsSince1970($m,$d,$y,$h,$mn,$s);

Dan

- - - - -
"I do not fear computer,
I fear the lack of them."
 -- Isaac Asimov

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBQLRvNiBNyqUzGb8RAlAzAJ4r4V/hk1GWEzX28CDz1fwmiFjizwCeORhs
s5fEKG9ilv4reqQ/cTMNUH8=
=4aXm
-----END PGP SIGNATURE-----


More information about the Omaha-pm mailing list