Forum


Calc Builder Support

Calc Builder support
Forums
No se permite escribir sin estar logado. Por favor, login

Date difference 18.07.2018 17:42

Hello,

I am experiencing trouble finding the difference between two dates. I have tested the code on other php editors and it has worked fine.
The code I have used is as follows:
$tax_2018=date_create("2018-4-5");
$ysp = $tax_2018->diff($DofP);
$ysp=$ysp->y;

DofP is a date input field. I am trying to find the number of years between 2018-4-5 and the date entered into DofP.
Any help would be appreciated.
Thanks,
Sam

Re: Date difference 19.07.2018 10:14

Hello,
the right way to do it would depend on the date format you set for your input field. We suggest to try to convert it directly into a date

$ysp = $tax_2018->diff(date_create($DofP));

in case you have set that same date format you're using for the fixed date "2018-4-5"


Hope this helps, regards
Moonsoft Team
www.moonsoft.es

Re: Date difference 19.07.2018 14:14

That did the trick, many thanks.
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect
FaLang translation system by Faboba

Lo que nuestros clientes opinan de nosotros