Re: Convert string into incremental date
- From: "DJ Stunks" <DJStunks@xxxxxxxxx>
- Date: 30 May 2006 17:10:20 -0700
Mothra wrote:
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
it helps me!
thanks,
-jp
.
- References:
- Convert string into incremental date
- From: djray
- Re: Convert string into incremental date
- From: Mothra
- Convert string into incremental date
- Prev by Date: Re: Date format conversion
- Next by Date: FAQ 3.27 Where can I learn about object-oriented Perl programming?
- Previous by thread: Re: Convert string into incremental date
- Next by thread: Re: Convert string into incremental date
- Index(es):
Relevant Pages
|