Re: Date Values

* Carl Nygard <cjnygard fast net> [2004-06-03 13:47]:
Use epoch seconds and Date::Manip is your friend.

No, don't use Date::Manip. From the POD [1]:


    If you look in CPAN, you'll find that there are a number of Date
    and Time packages. Is Date::Manip the one you should be using? In
    my opinion, the answer is no most of the time. This sounds odd
    coming from the author of the software, but read on.


There are numerous modules for manipulating dates that do more
narrowly defined tasks at least as well. Some of them have an
equally convenient interface. Among the choices:

* Date::Calc
* Time::Piece
* DateTime

The last is the basis of a very complete framework and would be
my favourite for anything slightly more complex. The first would
be my choice for the simple conversion task at hand.

    use POSIX qw(strptime strftime);

    my $date = "2004-06-03";
    my $epoch_time = strptime "%Y-%m-%d", $date;
    my $display_date = strftime "%d-%m-%Y", $epoch_time;

A large advantage is that is part of core, and therefor
doesn't add any external dependencies to the app.


"If you can't laugh at yourself, you don't take life seriously enough."

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]