Date Comparison

I need to get the current date and compare with my database date. The format of my date is "dd/mm/yyyy". I will only need to retrieve out data which are more than 30 days. It's best not to use modules for this problem i have. Thanks!
irene79Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
($d,$m,$y)=(localtime time-30*24*60*60)[3,4,5];
$m+=1; $y+=1900;

print "$mydate more than 30 days old\n" if( (join'',reverse split'/',$mydate) lt "$y$m$d" );
0
ozoCommented:
($d,$m,$y)=(localtime time-30*24*60*60)[3,4,5];
$m+=1; $y+=1900;
$old=sprintf"%04d%02d%02d",$y,$m,$d;
print "$mydate more than 30 days old\n" if( (join'',reverse split'/',$mydate) lt $old );
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
irene79Author Commented:
what's the $mydate? is it the date that i retrieve from the database? the date retrieve out from the database when i print it out , is in this format "1999-10-27 00.00.00" please advice
0
ozoCommented:
#Sorry, I thought you said $mydate was in the format dd/mm/yyyy
($S,$M,$H,$d,$m,$y)=(localtime time-30*24*60*60);
$m+=1; $y+=1900;
$old = sprintf "%04d-%02d-%02d %02d.%02d.%02d",$y,$m,$d,H,$M,$S;
print "$mydate more than 30 days old\n" if( $mydate lt $old );
0
irene79Author Commented:
Thanks ozo! it works :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.