Gossamer Forum
Home : Products : DBMan : Installation :

Default dates set 3 months in advance

Quote Reply
Default dates set 3 months in advance
Does anyone know an easy way of setting the default date so it is 3 months in advance.

Quote Reply
Re: Default dates set 3 months in advance In reply to
Oops!


[This message has been edited by mike1 (edited July 02, 1999).]
Quote Reply
Re: Default dates set 3 months in advance In reply to
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:

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





Quote Reply
Re: Default dates set 3 months in advance In reply to
I've tried this, but it just causes a server error, i copied the code exactly from your example into an unmodifed version 2.04 db.cgi file, do i need to change anything else ?

Quote Reply
Re: Default dates set 3 months in advance In reply to
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 "&#0124; &#0124;" to "or" in my own script so I don't post this again.


------------------
JPD





Quote Reply
Re: Default dates set 3 months in advance In reply to
Thanks that worked.