[Brisbane-pm] Convert string to date in Perl

Damian James djames at thehub.com.au
Tue Jan 30 20:11:23 PST 2007


Time::Local

Or roll you own regex, something like:

   my %date;
   $_ = '25/02/1990 23:48:00';
   @date{ qw/ day month year hour minute second/} = m<^(\d\d?)/(\d 
\d?)/(\d{4}) +(\d\d):(\d\d):(\d\d)>;
   $date{ minute } += 6;
   printf "%2d/%2d/%4d %2d:%2d:%2d", @date{ qw/ day month year hour  
minute second/};

Though use the module for maintainability.

Damian

On 31/01/2007, at 2:01 PM, Martin Jacobs wrote:

> Hi all,
>
> I would appreciate some help here.
>
> How do I convert a string to a date?
>
> Here's an example of the string...
>
> 25/02/1990 23:48:00
>
> I want to add on 6 minutes, so that the result is...
>
> 25/02/1990 23:54:00
>
> Thanks in advance.
>
> Regards,
> Martin Jacobs
> Visit my website...
> http://web.mac.com/martin_jacobs1
>
>
> _______________________________________________
> Brisbane-pm mailing list
> Brisbane-pm at pm.org
> http://mail.pm.org/mailman/listinfo/brisbane-pm



More information about the Brisbane-pm mailing list