Forums

Calculate expiration date

rafaelscouto 16 Apr, 2019
Good afternoon, how can I create a function that calculates an expiration date according to the date it was entered in the database (created).
Max_admin 16 Apr, 2019
{date:d-m-Y$(data:field_name_with_date)+100days}
The above code will take a date value coming from a field named "field_name_with_date" and add 100 days and return the date!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
rafaelscouto 16 Apr, 2019
How can I display this to the user?
Max_admin 16 Apr, 2019
if you have it in a "Custom code" or html then it will be displayed!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
rafaelscouto 16 Apr, 2019
I would like to create an expiration date.
A deadline of 10 days.
Where every day was reduced one day.
And after the deadline displays a message (Delayed Content).
I do not know how to do this.
healyhatman 16 Apr, 2019
What are you displaying it to the user in?

You can use PHP to calculate how many days it has been since a certain date, or if the current date is more than 10 days past the given date.

Then use a Switch Event on {var:php_block_name} to display the message if necessary.
rafaelscouto 16 Apr, 2019
I want to show the way it is in the image for the user.

healyhatman 16 Apr, 2019
So, in Chronoconnectivity? Use a PHP block in your column view, like
columnname:{fn:expiry_check$entry_date=(var:tableviewname.row.model.date)}
Then in the php block you've called expiry_check you can use $this->get("entry_date") to get the date and perform the calculation. Just echo out the text you want.
rafaelscouto 23 Apr, 2019
I did not understand with resolve this

what do I want to do? Get the value of the "created" field, format for dd/mm/YYYY and add 10 days and display this in a table.
healyhatman 23 Apr, 2019
You just want to display? Then
columnname:{date:d/m/Y$(var:tableviewname.row.model.created) +10 days}
rafaelscouto 23 Apr, 2019
It worked.

How can I get his value and make a calculation?

For example:

Get the value from when it was created and calculate with the value of the current day ...
healyhatman 23 Apr, 2019
https://www.php.net/manual/en/datetime.diff.php

You'll have to do it using PHP. Remember you can't use shortcodes in PHP, so for a {var:} call you would use $this->get("var_name") and for {data: you use $this->data("data_name")
healyhatman 30 Apr, 2019
Or in your Fields to Retrieve for your read data action, you can try
DATEDIFF(model.created , CURDATE()):model.calculated_date
Take note of the spaces around the comma
This topic is locked and no more replies can be posted.