Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to calculate the number of seconds between "now" and an ISO8601 date
So far I have the following code,
It's not working, so can someone suggest a working/better/more efficient way?use Time::Local; $start = '2013-10-28T18:59:52.863Z'; @parts = $start =~ /^(.{4})-(.{2})-(.{2})T(.{2}):(.{2}):(.{2})\.(.{3}) +Z$/; $start_secs = pop(@parts) / 1000; $start_secs += timegm reverse @parts; print "start_secs : $start_secs\n"; $end=timegm(gmtime()); print "end_secs : $end_secs\n"; $diff = $end_secs - $start_secs; print "$diff";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: time difference calculation
by RMGir (Prior) on Oct 28, 2013 at 12:36 UTC | |
by Anonymous Monk on Oct 28, 2013 at 12:43 UTC | |
by Corion (Patriarch) on Oct 28, 2013 at 12:51 UTC | |
|
Re: time difference calculation
by hdb (Monsignor) on Oct 28, 2013 at 12:51 UTC | |
by Anonymous Monk on Oct 28, 2013 at 13:35 UTC | |
|
Re: time difference calculation
by poolpi (Hermit) on Oct 28, 2013 at 12:41 UTC | |
|
Re: time difference calculation
by marinersk (Priest) on Oct 28, 2013 at 13:37 UTC | |
|
Re: time difference calculation
by Anonymous Monk on Oct 28, 2013 at 12:56 UTC | |
|
Re: time difference calculation
by kcott (Archbishop) on Oct 29, 2013 at 08:09 UTC |