Page 1 of 1

[Insert record]how to set expiry date field {NOW_DT}+31days?

Posted: 2012-09-18 22:30
by antonio
Hi all,
I have an insert record form on a page.
I have a field that set an expiry date for the record.
This date should be 31 days away from today (in interakt language: {NOW_DT}+31 days).

I tried to set the date this way:

Code: Select all

$expiry_date = KT_formatDate(date("Y-m-d", time() + 60*60*24*31));
and then added this variable in the insert transaction:

Code: Select all

$ins_files->addColumn("data_scad_fil", "DATE_TYPE", "POST", "data_scad_fil", "{GLOBALS.expiry_date}");
But it doesn't work. :(

Any suggestion will be really appreciated.

TIA

tony

Re: [Insert record]how to set expiry date field {NOW_DT}+31d

Posted: 2012-09-19 10:38
by Fred

Code: Select all

$exp_date = date("Y-m-d", strtotime("+31 days"));
Easiest is to set it as a hidden field when you build your form.

Re: [Insert record]how to set expiry date field {NOW_DT}+31d

Posted: 2012-09-19 10:50
by antonio
Fred wrote:

Code: Select all

$exp_date = date("Y-m-d", strtotime("+31 days"));
Easiest is to set it as a hidden field when you build your form.
Thanks Fred,
I already have an hidden field called "expiry_date" but how can I assign it the correct date (today+31days)?
I already tried (without success) to set something like this "{NOW_DT}+time()+60*60*24*31...

Thanks again, Fred.
I'll test your code now.

ciao

tony

Re: [Insert record]how to set expiry date field {NOW_DT}+31d

Posted: 2012-09-19 11:21
by Fred
Add this to your page to convince yourself it is actually doing the calculation.

Code: Select all

<?php
     echo date("Y-m-d", strtotime("+31 days"));
?>
Then just move the line of code and set it as the value of the hidden field.

Code: Select all

<input type="hidden" name="exp_date" id="exp_date" value="<?php echo date("Y-m-d", strtotime("+31 days")); ?>" />