Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Time Formatting....

by mpd (Monk)
on Aug 04, 2003 at 06:04 UTC ( [id://280568]=note: print w/replies, xml ) Need Help??


in reply to Time Formatting....

One way to do it yourself would be:
# assuming $_session_time is in seconds. my $_session_time = $session{time_then}; my $_current_time = time(); my $_time_now = ($_current_time-$_session_time); my $minutes = int($_time_now / 60); my $seconds = $_time_now % 60;

Though this will likely fail during time changes if they are observed where this code is being run.

Alternatives include DateTime, Date::Calc, and Date::Manip.

Code lightly tested. "It works for me."

Replies are listed 'Best First'.
Re: Re: Time Formatting....
by Mr_Person (Hermit) on Aug 04, 2003 at 18:55 UTC
    In addition to those modules I would recommend taking a look at Date::Format. It may not have as many features as the other ones, but for simple formatting like you are wanting to do it is very easy and straightforward to use. Also included in that distribution is Date::Parse which can be used to parse simple dates which I find useful for when you are fairly certain what format a date will be entered in but want to be a little flexible with the user.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://280568]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-25 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found