my @dim =(0,31,28,31,30,31,30,31,31,30,31,30,31);

my @timeData = localtime(time);
my $hr=$timeData[2];
my $min=$timeData[1];
my $sec=$timeData[0];
my $dt=$timeData[3];
my $mnt=$timeData[4] + 1;
my $yr =$timeData[5] + 1900;

my $t1 = 2012-09-21 14:27:00';
my $t2 = "$mnt\-$dt\-$yr $hr:$min:$sec";

print "The difference between $yr\-$mnt\-$dt $hr:$min:$sec and $at";
$mnt =~ s/09/9/;
$mnt =~ s/08/8/;
$mnt =~ s/07/7/;
$mnt =~ s/06/6/;
$mnt =~ s/05/5/;
$mnt =~ s/04/4/;
$mnt =~ s/03/3/;
$mnt =~ s/02/2/;
$mnt =~ s/01/1/;

$dt =~ s/09/9/;
$dt =~ s/08/8/;
$dt =~ s/07/7/;
$dt =~ s/06/6/;
$dt =~ s/05/5/;
$dt =~ s/04/4/;
$dt =~ s/03/3/;
$dt =~ s/02/2/;
$dt =~ s/01/1/;

$da[1] =~ s/09/9/;
$da[1] =~ s/08/8/;
$da[1] =~ s/07/7/;
$da[1] =~ s/06/6/;
$da[1] =~ s/05/5/;
$da[1] =~ s/04/4/;
$da[1] =~ s/03/3/;
$da[1] =~ s/02/2/;
$da[1] =~ s/01/1/;

$da[2] =~ s/09/9/;
$da[2] =~ s/08/8/;
$da[2] =~ s/07/7/;
$da[2] =~ s/06/6/;
$da[2] =~ s/05/5/;
$da[2] =~ s/04/4/;
$da[2] =~ s/03/3/;
$da[2] =~ s/02/2/;
$da[2] =~ s/01/1/;

$t1[0] =~ s/09/9/;
$t1[0] =~ s/08/8/;
$t1[0] =~ s/07/7/;
$t1[0] =~ s/06/6/;
$t1[0] =~ s/05/5/;
$t1[0] =~ s/04/4/;
$t1[0] =~ s/03/3/;
$t1[0] =~ s/02/2/;
$t1[0] =~ s/01/1/;
$t1[0] =~ s/00/0/;

$t1[1] =~ s/09/9/;
$t1[1] =~ s/08/8/;
$t1[1] =~ s/07/7/;
$t1[1] =~ s/06/6/;
$t1[1] =~ s/05/5/;
$t1[1] =~ s/04/4/;
$t1[1] =~ s/03/3/;
$t1[1] =~ s/02/2/;
$t1[1] =~ s/01/1/;
$t1[1] =~ s/00/0/;

$t1[2] =~ s/09/9/;
$t1[2] =~ s/08/8/;
$t1[2] =~ s/07/7/;
$t1[2] =~ s/06/6/;
$t1[2] =~ s/05/5/;
$t1[2] =~ s/04/4/;
$t1[2] =~ s/03/3/;
$t1[2] =~ s/02/2/;
$t1[2] =~ s/01/1/;
$t1[2] =~ s/00/0/;

my $ds=0;
my $dmin=0;
my $dhr =0;
my $dd=0;
my $dm =0;
my $dy=0;
if($yr % 4 == 0)
{
$dim[2] = 29;
}
if($sec < $t1[2])
{

$sec = $sec + 60;
$min = $min -1;
$ds = $sec - $t1[2];


}
else
{

$ds = $sec - $t1[2];
}

if($min < $t1[1])
{

$min = $min + 60;
$hr = $hr -1;

$dmin = $min - $t1[1];
}
else
{

$dmin = $min - $t1[1];
}

if($hr < $t1[0])
{
$hr = $hr + 24;
$dt = $dt -1;

$dhr = $hr - $t1[0];
}
else
{
$dhr = $hr - $t1[0];
}

if($dt < $da[2])
{
$dt = $dim[$mnt] + $dt;
$mnt = $mnt -1;

$dd = $dt - $da[2];
}
else
{
$dd = $dt - $da[2];
}

if($mnt < $da[1])
{
$mnt = $mnt + 1;
$yr = $yr -1;

$dm = $mnt - $da[1];
}
else
{
$dm = $mnt - $da[1];
}
$dy = $yr - $da[0];


print " is YEAR $dy MONTH $dm DAYS $dd HOURS $dhr MINUTES $dmin SEC $ds <br>";


#here is the output
#The difference between 2012-9-24 8:39:12 and 2012-09-21
# 14:27:00is YEAR 2012 MONTH 9 DAYS 24 HOURS 8
#MINUTES 39 SEC 12