years of age, months and days
Posted: 2020-02-16 17:42
I'm a beginner programming
// calculate age in years, months and days
// I put the function: (In the hook folder, file "unit")
function unit_init (& $ options, $ memberInfo, & $ args) {
if (isset ($ _ REQUEST ['SelectedID'])) {
$ id = makeSafe ($ _ REQUEST ['SelectedID']);
$ today = date ('Y-m-d');
sql ("update unit set age = floor (datediff ('{$ today}', date) / 365.25) where id = '{$ id}'", $ eo);
}
// show age = correct
// but as I show months and days
// calculate age in years, months and days
// I put the function: (In the hook folder, file "unit")
function unit_init (& $ options, $ memberInfo, & $ args) {
if (isset ($ _ REQUEST ['SelectedID'])) {
$ id = makeSafe ($ _ REQUEST ['SelectedID']);
$ today = date ('Y-m-d');
sql ("update unit set age = floor (datediff ('{$ today}', date) / 365.25) where id = '{$ id}'", $ eo);
}
// show age = correct
// but as I show months and days
