Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: time format

by thanos1983 (Parson)
on Jan 14, 2019 at 15:14 UTC ( [id://1228537]=note: print w/replies, xml ) Need Help??


in reply to time format

Hello bigup401,

Fellow Monks have already proposed solutions to your problem. I would like to add also another possible way.

I prefer to use the module Date::Manip regarding Date/Time manipulations/calculations. You can find also here a few basic examples Date::Manip::Examples.

#!/usr/bin/perl use strict; use warnings; use Date::Manip; use feature 'say'; my $date1 = ParseDate("now"); my $date2 = ParseDate("2 hours ago"); my $delta = DateCalc($date1, $date2, 1); say $delta; say Delta_Format($delta,"Was %hv hours, %mv minutes, %sv seconds"); __END__ $ perl test.pl 0:0:0:0:-2:0:0 Was -2 hours, 0 minutes, 0 seconds

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-29 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found