This topic is locked

date add

1/7/2008 9:44:53 AM
PHPRunner General questions
G
garethp authorDevClub member

I think this is a simple one but I just can not get it to work.
I would like the default value of a date field to be the current date plus 3 days when the user adds a new record.
I can get the curent date easily by using now() as the default in visual editor.
Any help would be greatly appreciated.

G
giles 1/8/2008

I think this is a simple one but I just can not get it to work.

I would like the default value of a date field to be the current date plus 3 days when the user adds a new record.
I can get the curent date easily by using now() as the default in visual editor.
Any help would be greatly appreciated.


Gareth,

Here's one way...

PHP allows the addition of units of time to a date. Here's an example.
$datewewant = date("Y-m-d", strtotime($values["DateField"]." + ".$values["MthsToAdd"]. " months"));
You'll need to look up the php date function to check the exact syntax for adding 3 days to now()...
Then use either the default value in Visual Editor or a before display event to set the default.
Good luck.
Giles

G
giles 1/8/2008

I think this is a simple one but I just can not get it to work.

I would like the default value of a date field to be the current date plus 3 days when the user adds a new record.
I can get the curent date easily by using now() as the default in visual editor.
Any help would be greatly appreciated.


Gareth,

Here's one way...

PHP allows the addition of units of time to a date. Here's an example.
$datewewant = date("Y-m-d", strtotime($values["DateField"]." + ".$values["MthsToAdd"]. " months"));
You'll need to look up the php date function to check the exact syntax for adding 3 days to now()...
Then use either the default value in Visual Editor or a before display event to set the default.
Good luck.
Giles