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

Any tips and tricks that has to with the ADDT that doesn't fit into one of the other categories
antonio
Posts: 77
Joined: 2010-09-28 11:48

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

Post by antonio » 2012-09-18 22:30

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

User avatar
Fred
Site Admin
Posts: 491
Joined: 2010-02-15 12:10
Location: Armagh, Northern Ireland
Contact:

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

Post by Fred » 2012-09-19 10:38

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.

antonio
Posts: 77
Joined: 2010-09-28 11:48

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

Post by antonio » 2012-09-19 10:50

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

User avatar
Fred
Site Admin
Posts: 491
Joined: 2010-02-15 12:10
Location: Armagh, Northern Ireland
Contact:

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

Post by Fred » 2012-09-19 11:21

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")); ?>" />

Post Reply