I have forced user to add the three fields, date,month,year.
#changed to JPDeni date http://webmagic.hypermart.net/dbman/calc42.txt
sub get_date {
# --------------------------------------------------------
# Returns the date in the format "dd-mmm-yy".
# Warning: If you change the default format, you must also modify the &date_to_unix
# subroutine below which converts your date format into a unix time in seconds for sorting
# purposes.
$time = $_[0];
($time) || ($time = time());
# be sure to remove the space between the two | characters in the line above.
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
++$mon;
($mon < 10) and ($mon = "0$mon");
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$day-$mon-$year";
}
#changed to JPDeni date http://webmagic.hypermart.net/dbman/calc42.txt
#due to want to count age of user
sub date_to_unix {
# --------------------------------------------------------
# This routine must take your date format and return the time a la UNIX time().
# Some things to be careful about..
# int your values just in case to remove spaces, etc.
# catch the fatal error timelocal will generate if you have a bad date..
# don't forget that the month is indexed from 0!
#
my ($date) = $_[0];
my ($time);
my ($day, $mon, $year) = split(/-/, $_[0]);
unless ($day and $mon and $year) { return undef; }
use Time::Local;
eval {
$day = int($day); $mon = int($mon) - 1 ; $year = int($year) - 1900;
$time = timelocal(0,0,0,$day,$mon,$year);
};
if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}
I want to have a page list of record that have the date and month match to server date and month.Such as if to day is 09-02-2001,the records which have date match to server date will be listed on a page.
Any comment or please help me code it if you know how to.
Regards,
Act.
I am new to cgi, Thank you for your help.
#changed to JPDeni date http://webmagic.hypermart.net/dbman/calc42.txt
sub get_date {
# --------------------------------------------------------
# Returns the date in the format "dd-mmm-yy".
# Warning: If you change the default format, you must also modify the &date_to_unix
# subroutine below which converts your date format into a unix time in seconds for sorting
# purposes.
$time = $_[0];
($time) || ($time = time());
# be sure to remove the space between the two | characters in the line above.
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
++$mon;
($mon < 10) and ($mon = "0$mon");
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$day-$mon-$year";
}
#changed to JPDeni date http://webmagic.hypermart.net/dbman/calc42.txt
#due to want to count age of user
sub date_to_unix {
# --------------------------------------------------------
# This routine must take your date format and return the time a la UNIX time().
# Some things to be careful about..
# int your values just in case to remove spaces, etc.
# catch the fatal error timelocal will generate if you have a bad date..
# don't forget that the month is indexed from 0!
#
my ($date) = $_[0];
my ($time);
my ($day, $mon, $year) = split(/-/, $_[0]);
unless ($day and $mon and $year) { return undef; }
use Time::Local;
eval {
$day = int($day); $mon = int($mon) - 1 ; $year = int($year) - 1900;
$time = timelocal(0,0,0,$day,$mon,$year);
};
if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}
I want to have a page list of record that have the date and month match to server date and month.Such as if to day is 09-02-2001,the records which have date match to server date will be listed on a page.
Any comment or please help me code it if you know how to.
Regards,
Act.
I am new to cgi, Thank you for your help.