Forums

Age calculation

Fasano 10 May, 2017
Good morning
I'm managing master data with Chronoform5.
Wanting to show on my site the names of boys who make the years, I have built one
Connection with ChronoConnectivity5. So as a condition I have

<?php
$today = date('%-m-d');
return array('visualizza.eliminare' => '1' ,'visualizza.data LIKE' => "%$today%");
?>

In frontlist I wrote

<td ><?php
$alfa="{visualizza.immagine}";
$beta='<img class="img-thumbnail" WIDTH="150" src="' ;
$gamma = 'http://' . $_SERVER['HTTP_HOST'] . "/" . basename(dirname($_SERVER['PHP_SELF']));
$delta="/images/per_database/upload/foto/";
$teta='" />';
echo $beta.$bet.$gamma.$delta.$alfa.$teta ;
?></td>
</tr>
<tr>
<td><font face="Verdana" size="4" >{visualizza.cognome} </font></td>


</tr>
<td><font face="Verdana" size="3" >{visualizza.nome} </font></td>

<tr>
<td><font face="Verdana" size="2" >{visualizza.data}</td>
</tr>

The final result shows me the photo with the name, last name and date of birth.

Now I wanted to see the writing instead of the date of birth. "What is now twenty years old!"
I've tried and tried different formulas but nothing ... I can not really calculate the years since birth.

How can I do?
Thank you
Max_admin 11 May, 2017
Hi Fasano,

For new connections you should use v6 because it offers much more flexibility.

In this case here in v5, you will need to use php to do the calculation, but the code depends on the "data" field format, in which format do you have the date stored ?

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Fasano 11 May, 2017
Ho Mac
The date format is Y-m-d
Max_admin 11 May, 2017
Answer
Hi Fasano,

So you can try this PHP code instead:

<?php
echo date("Y") - date("Y", strtotime($row["visualizza"]["data"]));


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Fasano 11 May, 2017
1 Likes
Hi Max
perfetto
thank you very much

Best regards
Fasano
This topic is locked and no more replies can be posted.