<?xml version="1.0" encoding="windows-1252"?>
<node id="76235" title="Re: parsing date string" created="2001-04-27 19:14:58" updated="2005-07-19 14:08:39">
<type id="11">
note</type>
<author id="16834">
OeufMayo</author>
<data>
<field name="doctext">
&lt;p&gt;Though [cpan://Date::Manip] is certainly able to do this kind of operations, I would not recommand using it. In fact neither the author of this module:&lt;br /&gt;
&lt;i&gt;  Is Date::Manip the one you should be using?  In my opinion, the answer is no about 90% of the time.  This sounds odd coming from the author of the software, but read on.&lt;br /&gt;Date::Manip is written entirely in perl.  It's the most powerful of the date modules.  It's also the biggest and slowest.&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;There are plenty of specialized module in the Date::* hierarchy that can fill the bill. For instance, I would use [cpan://Time::Local] for this kind of job, but I'm sure one could find a better suited module (maybe [cpan://Date::Format]?). Anyway here's a stab at it:&lt;/p&gt;
&lt;code&gt;
  use Time::Local;

  my $time1 = '010101112245';
  my $time2 = '010101114556';

  foreach ($time1, $time2){
    my @t = $time1 =~ /(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/;
    @t = reverse @t;
     $_ = timelocal(@t);
  }

 print "Difference is: ", ($time1 -$time2), "\n";
&lt;/code&gt;
&lt;p&gt;&lt;small&gt;&lt;b&gt;Disclaimer&lt;/b&gt;: Code barely tested, not to be used to operate nuclear reactors.&lt;/small&gt;&lt;/p&gt;

&lt;kbd&gt;-- &lt;br&gt;
my $&lt;a href="/index.pl?node=OeufMayo&amp;lastnode_id=1072"&gt;OeufMayo&lt;/a&gt; = new PerlMonger::Paris({http =&gt; '&lt;a href="http://paris.mongueurs.net"&gt;paris.mongueurs.net&lt;/a&gt;'});&lt;/kbd&gt;</field>
<field name="root_node">
76218</field>
<field name="parent_node">
76218</field>
</data>
</node>
