Re: Convert string into incremental date
- From: "Mothra" <mothra@xxxxxxxxxxxxxxxx>
- Date: Tue, 30 May 2006 16:06:00 -0700
djray wrote:
My question is two part:
1. I am reading a date from a file in the form mm/dd/yy (i.e.
05/30/06). I need to convert that string into a date.
2. I need to be able to increment that date:
Example:
$date = 05/30/06;
$date = $date + 1; ($date = 05/31/06)
$date = $date + 1; ($date = 06/01/06)
Any help would be greatly appreciated.
-Ray
This might get you started :-)
use strict;
use warnings;
use DateTime;
use DateTime::Duration;
use DateTime::Format::Strptime;
my $Strp = new DateTime::Format::Strptime(
pattern => '%m/%d/%y',
time_zone => 'GMT',
);
my $dur = DateTime::Duration->new( days => 1 );
while (<DATA>) {
chomp;
my $dt = $Strp->parse_datetime($_);
print $dt + $dur;
}
__DATA__
05/31/06
06/01/06
I hope this helps
Mothra
.
- Follow-Ups:
- Re: Convert string into incremental date
- From: DJ Stunks
- Re: Convert string into incremental date
- References:
- Convert string into incremental date
- From: djray
- Convert string into incremental date
- Prev by Date: Re: John Bokma harassment
- Next by Date: Re: Convert string into incremental date
- Previous by thread: Re: Convert string into incremental date
- Next by thread: Re: Convert string into incremental date
- Index(es):
Relevant Pages
|