Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Time Formatting....

by mpd (Monk)
on Aug 04, 2003 at 06:04 UTC ( #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? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2021-12-04 17:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (30 votes). Check out past polls.

    Notices?