On Apr 21, 2011 12:17 PM, "Karl Kaufman" <krk...@comcast.net> wrote: > > Alternatives to shawn's response (w/o commenting on relative benefits)...
You won't mention the benefits, but I will... :) > > ----- Original Message ----- From: "cc" <c...@belfordhk.com> > To: <beginners@perl.org> > Sent: Thursday, April 21, 2011 4:37 AM > Subject: time format conversion > >> Hi, >> >> I have two strings that shows different times and I >> want to find the difference in # of hours. >> >> In PHP, there's strtotime(), but there isn't one >> in Perl that I can find. > Now that we've gotten into this, why do you only have one way to manipulate dates in php? Isn't that sorta limiting? > > If loading additional modules is an option, the following can be of use... > If he's using perl and can't install modules on the destination computer, he might want to consider par before anything else. > Date::Manip > http://search.cpan.org/~sbeck/Date-Manip-6.23/lib/Date/Manip.pod > Date::Calc > http://search.cpan.org/~stbey/Date-Calc-6.3/lib/Date/Calc.pod > d:manip is cool. I started out using it. But then I found it too limiting. This is explained in the three paragraphs from the below link I've pasted for reference. > see also: The Many Dates and Times of Perl > http://www.perl.com/pub/2003/03/13/datetime.html > But I want convenience. If I'm dealing with many datetimes and I need to parse various inputs, generate different formats, and do lots of calculations, then a convenient and uniform API can go a long way towards code maintainability. The extra glue code needed to make different modules cooperate can quickly obscure the actual intent of the program. Efforts in the past to herd all the existing module authors towards a common API have failed, so rather than try that again, I decided to just write even more datetime code. As we all know, the best way to put out a fire is to pour copious amounts of gasoline on it. In order to make my project sound cool, I'm calling it the "Perl DateTime Suite", which sounds much better than "more date and time modules". The goal for this project is to produce a suite of datetime modules that do everything you'd ever need related to dates and times. The modules in this suite will cooperate with each other, which means that a module that parses datetimes will return a standard object, and a module for formatting datetimes will accept that standard object.