to add a function in a php file

We have a php file that get a price from a database using this URL (that provides 3 variables: breed + age + postalcode)

[login to view URL]

Now we need that the age variable, instead of being by years (1,2,3,4…), should be by date: 27/01/2018

like in here: [login to view URL]

For that I need to include a function that convert the age date from a date (27/01/2018) to a year range…

Dates from 1 day to 1 year, should be 1

Dates from 1 year to 2 ears should be 2

Dates from 2 years to 3 years should be 3


i.e. 27/01/2018 should be converted to 2 , because from that date to today there is more than 1 year and less than 2 years.

I have already the function, but I don’t know hoy to include it in the api

See the function below:

function age_range($initial_date){

$initialdate = new DateTime($initial_date);

$finaldate = new DateTime('now');

$diference = $initialdate->diff($finaldate);

// the diff method provide an objet DateInterval,

// that keeps the information about the differnet time period

// between dates (yeasr, months, days, etc.).

$months = ( $diference->y * 12 ) + $diference->m;

// To calculate the number of months we have to multiply “y” times 12

// (number of months in a year). After that we add the value saved

// to “m“, that contains the number of months of our age range.


1 is from 2 months upto 1 year

2 is from 1 year upto 2 year

3 is from 2 upto 3

4 is from 3 upto 4

5 is from 4 upto 5

6 is from 5 upto 6

7 is from 6 upto 7


if ( $months >= 2 and $months <= 12 ) { return 1; }

if ( $months >= 13 and $months <= 24 ) { return 2; }

if ( $months >= 25 and $months <= 36 ) { return 3; }

if ( $months >= 37 and $months <= 48 ) { return 4; }

if ( $months >= 49 and $months <= 60 ) { return 5; }

if ( $months >= 61 and $months <= 72 ) { return 6; }

if ( $months >= 73 and $months <= 95 ) { return 7; }


Compétences : HTML, Javascript, MySQL, PHP, Architecture Logicielle

en voir plus : function conver file csv html php, add rss function php website, add language oscommerce php file, php call function from another file, php functions list, php function return, types of functions in php, call php function from html, php function parameters, php built in functions, php include, html file add function method, add video function php script, php file upload function, add jobs upload file php, add tab csv file php, function php add item, multiple file upload add upload php, onchange add file input function php, php add function

Concernant l'employeur :
( 21 commentaires ) Sevilla, Spain

Nº du projet : #19620881

Décerné à:


Greetings, I understood what you are trying to achieve but than I am little confused too. You are saying that below API call gives you price- [login to view URL] Plus

%selectedBids___i_sum_sub_4% %project_currencyDetails_sign_sub_5% EUR en 1 jour
(2 Commentaires)

42 freelance font une offre moyenne de €26 pour ce travail


I am experienced php developer and web designer with the depth knowledge related to MySQL,Laravel,WordPress,MSSQL,JSON,JAVASCRIPT,AJAX,XML,jQuery,CSS,HTML5,Material Designing with the integration of web technologies. Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(365 Commentaires)

Hi I can write the function as you want. Hire me please. Thank you! .

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(607 Commentaires)

Hello, I read your Job Description and I can add a function into the PHP file of API and complete your Project perfectly, you will get satisfied result… I have Skills in PHP, MySQL, HTML5, CSS3, LESS/Sass/SCSS, JavaScr Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% EUR en 2 jours
(265 Commentaires)

Greetings sir, I have read your project details and i will add the function to your php file right away. Sir, i can deliver this project sooner than you expect and will be over your satisfaction level. Please Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(187 Commentaires)

Lets get it done. I am available to take up this job. Please check my reviews and then decide on me. PHP Programmer with 10+ years of experience. Please let me know if you have any questions. Thanks, Ajit

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(283 Commentaires)

Hi There, I can add a function in a php file.I have read your job description and assure you that I am a perfect fit for the job. My Expertise:- =========== > PHP, HTML, CSS, javascript/jquery, API integration,Word Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(141 Commentaires)

Hello hiring member i hope you are doing well i am bhavika i have 3+years experience in php ,laravel , ajax , jquery , javascript , html ,css , bootstrap so i can do it so please give me chance to serve you thanks in a Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(133 Commentaires)
%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(263 Commentaires)

Hello, I have 18 years of coding experience. This is a very easy task for me which I can accomplish within a couple of hours. Ready to fix it right away for you. Thanks

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(136 Commentaires)

Hi there, Greetings from TechPlus! I've reviewed requirements & ready to add a function in a php file. 5+ Years Expertise in : CMS (Wordpress, Magento, Shopify, OpenCart, Joomla, Drupal, Prestashop) PHP Fram Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(98 Commentaires)

I have being working as php developer since 8 years in which 4 Years I have being working as joomla developer. I have also worked in Magento, cake php, wordpress, prestashop, boonex, osccomerce, opencart ect websites w Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(100 Commentaires)

Hi, I have read your project description this will be done in your required time spam with 100% Satisfaction. Kindly message me so we can discuss in detail over chat......

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(94 Commentaires)

Hi, I have checked the work scope and can fixed the date format too " (27/01/2018) " Please initiate a chat session for more discussion about the project. I am looking forward to working with you. Thanks for readin Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(142 Commentaires)

Hey, I have gone through your post and pretty simple to add this function into code but before that I need to study your code so I can provide you best solution at reasonable price. Let's connect to discuss your re Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(40 Commentaires)

Hello there, I have got 5 years of web development experience including PHP, MySQL, Laravel, I can work on that function for you and I can start work immediately.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(16 Commentaires)

Dear Sir. I am interested in your project. I'm senior PHP, SQL, Javascript developer. I assure, I will do my best to work with you on your project to present the best possible outcome for you and your customers. I w Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(109 Commentaires)

Hi I am software engineer and full stack PHP developer your project is looking very interesting and I am looking forward to your message

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(88 Commentaires)

Hello, I can do the work and can start working now. Please message me for further discussion. Best Regards, Zaiyan

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(42 Commentaires)

Thank you for posting a Job. I WILL DO THIS AS PER YOUR REQUIREMENT AND EXPECTATIONS. With the experience of over 300+web development projects including ANDROID, IOS, WEBSITES, WEB APPLICATIONS AND SOFTWARE Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(37 Commentaires)

Hi I read your requirements carefully. I have experience in php. If you give me the assignment, I will satisfy u with good result. If you want to, I can show you the source code of the tasks I have already done. I Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(38 Commentaires)