Hot Pastrami has asked for the wisdom of the Perl Monks concerning the following question:

Hey everybody...

I have not yet done any significant date manipulation in Perl, so the question I came across today has left me a bit at a loss... I have a script which spits out an XML document created on-the-fly from a database. The database stores dates as days-since-the-epoch, for instance today would be 11352 ... it's basically like this at the time it's stored in the database:
$date = time() / 60 / 60 / 24;

...and I have no control over that portion. So my question is this: What is the best way to convert this back to a conventional format, such as 2000/01/30 ? Is there a particularly well-suited module?

Thanks,

Hot Pastrami

Replies are listed 'Best First'.
(tye)Re: Date Conversion
by tye (Sage) on Jan 31, 2001 at 00:32 UTC
    localtime($val*60*60*24)
            - tye (but my friends call me "Tye")
Re: Date Conversion
by AgentM (Curate) on Jan 31, 2001 at 00:37 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Date Conversion
by flocto (Pilgrim) on Jan 31, 2001 at 09:33 UTC
    Are you sure your database can't help you with that? I prefer letting the database doing that kind of stuff for me (because I am extremely lazy and it might even be faster, who knows..). And at least MySQL has some really neat date/time-convertion-functions. I'm pretty sure that commercial SQL-DBs have these kind of functions, too..
    Regards, octopus

    --
    GED/CC d-- s:- a--- C++(+++) UL+++ P++++$ L++>++++ E--- W+++@ N o? K? w-- O- M-(+) V? !PS !PE !Y PGP+(++) t-- 5 X+ R+(+++) tv+(++) b++@ DI+() D+ G++ e->+++ h!++ r+(++) y+