Does anyone know an easy way of setting the default date so it is 3 months in advance.
Jul 2, 1999, 8:47 AM
Veteran / Moderator (8669 posts)
Jul 2, 1999, 8:47 AM
Post #3 of 6
Views: 2412
You can easily get it to set the default date to 90 days from the current date. That would mean that records added today would have "30-Sep-1999" instead of "02-Oct-1999." If that's okay, here's what you do.
The first thing you'll need to do is to make an adjustment to sub get_date in db.cgi.
Replace it with the following:
# --------------------------------------------------------
# Returns the date in the format "dd-mmm-yyyy".
# 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());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}
Then, in your .cfg file, for the field you want the future date in, use
&get_date(time() + 7776000)
as the default value. Don't put single quotes around it.
------------------
JPD
The first thing you'll need to do is to make an adjustment to sub get_date in db.cgi.
Replace it with the following:
Code:
sub get_date { # --------------------------------------------------------
# Returns the date in the format "dd-mmm-yyyy".
# 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());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}
Then, in your .cfg file, for the field you want the future date in, use
&get_date(time() + 7776000)
as the default value. Don't put single quotes around it.
------------------
JPD
Jul 5, 1999, 10:08 AM
Veteran / Moderator (8669 posts)
Jul 5, 1999, 10:08 AM
Post #5 of 6
Views: 2408
I keep forgetting something.
You have to take out the space between the two | characters. The forum software for some reason adds a space.
I'm going to go change the "| |" to "or" in my own script so I don't post this again.
------------------
JPD
You have to take out the space between the two | characters. The forum software for some reason adds a space.
I'm going to go change the "| |" to "or" in my own script so I don't post this again.
------------------
JPD