CalcBuilder Forum

Convert # of days into Years Months Days

Usuario phil_adler 2016-02-10 19:36:20

My calculator will output the total number of days between to dates. How can I take that number and convert it to years months days for example 366 days would out put 1 year 0 months 1 day

Edited by phil_adler - 10.02.2016 19:36

Moonsoft support 2016-02-10 19:41:13

in fact there is no an exact solution to that problem, because not every year has same number of days and also months have different number of days, but you can get an approximation. Here you can find the code to get that solution:

Hope this helps, regards

Usuario phil_adler 2016-02-10 20:09:07

I was afraid of that. :-(

Moonsoft support 2016-02-10 20:49:15

yes, sorry, it's not a calculation that you can't do in php, is a calculation that you can't do in real life either...


Perfect for small code changes or to correct any bug at your site

Buy now!

Create dynamic calculators

Buy now!