in reply to time elapsed from set time
G'day sjwnih111,
Welcome to the monastery.
If you're just looking for a difference between that time today and the current time today, you can use the builtin module, Time::Piece, like this:
$ perl -Mstrict -Mwarnings -le ' use Time::Piece; my $now = gmtime; my $now_Ymd_date = sprintf "%4s%02s%02s", $now->year, $now->mon, $ +now->mday; my $then_HMS_time = "082802"; my $then_date_time = $now_Ymd_date . $then_HMS_time; my $then = Time::Piece->strptime($then_date_time, "%Y%m%d%H%M%S"); print "Then: ", $then->strftime("%Y-%m-%d %H:%M:%S"); print "Now: ", $now->strftime("%Y-%m-%d %H:%M:%S"); print "Now - Then: ", $now - $then, " seconds"; ' Then: 2013-09-11 08:28:02 Now: 2013-09-11 01:44:18 Now - Then: -24224 seconds
Note that gives a negative time difference because it's not elapsed time at all, it's ~7 hours in the future. To get an elapsed time, you'll need to provide a date and time in the past to compare with the current date and time. This is what hippo was referring to.
Of course, if you're piloting a time machine, negative elapsed times might be entirely appropriate. :-)
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: time elapsed from set time
by sjwnih111 (Novice) on Sep 13, 2013 at 17:57 UTC |