全部博文(1144)
分类: LINUX
2009-12-09 11:48:02
#!/usr/local/bin/perl # # util to find the time between two dates # (specifically, i use this to find out how many months old my kids are) # use CGI qw(:standard); use Date::Manip; my $q = new CGI(); print $q->header(), $q->start_html('Get Age'), $q->start_form(), "Start Date: ", $q->popup_menu(-name=>'start_auto', -values=>['','19980101','20000101','20010101'], -default=>['']), $q->textfield('start_manual'), "
\n", "End Date: ", $q->textfield('end',`date +%Y%m%d`), "
\n", "format: YYYYMMDD
\n", $q->submit(), "
\n"; if( ( ($start=$q->param('start_auto')) || ($start=$q->param('start_manual')) ) && (my $end=$q->param('end')) ){ my ($years,$months,$weeks,$days,$hours,$minutes) = split /:/, &DateCalc($start,$end,\$err,1); my $totalmonths = $months + abs($years) * 12; print "$totalmonths months between $start and $end
\n", "($years years, $months months, $weeks weeks, $days days, $hours hours, $minutes minutes, $sec onds seconds)
\n"; } print $q->end_html();