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; }


Skills: HTML, Javascript, MySQL, PHP, Software Architecture

See more: 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

About the Employer:
( 22 reviews ) Sevilla, Spain

Project ID: #19620881

Awarded to:


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] More

€16 EUR in 1 day
(6 Reviews)

38 freelancers are bidding on average €26 for this job


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. More

€29 EUR in 1 day
(418 Reviews)

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

€20 EUR in 1 day
(611 Reviews)

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 More

€35 EUR in 2 days
(274 Reviews)

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 More

€30 EUR in 1 day
(194 Reviews)

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 More

€30 EUR in 1 day
(180 Reviews)

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

€25 EUR in 1 day
(285 Reviews)

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 More

€30 EUR in 1 day
(154 Reviews)

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

€14 EUR in 1 day
(136 Reviews)

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......

€17 EUR in 1 day
(143 Reviews)
€29 EUR in 1 day
(289 Reviews)

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 More

€50 EUR in 1 day
(142 Reviews)

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 More

€30 EUR in 1 day
(117 Reviews)

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 More

€23 EUR in 1 day
(101 Reviews)

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 More

€30 EUR in 1 day
(42 Reviews)

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

€24 EUR in 1 day
(103 Reviews)

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.

€25 EUR in 1 day
(16 Reviews)

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

€23 EUR in 1 day
(45 Reviews)

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 More

€23 EUR in 1 day
(39 Reviews)

Hi, I have read your project description. I am very confident to provide your PSD to Wordpress design. I have great experience in Wordpress, Shopify, Woo-Commerce, Php, Javascript, HTML5, CSS3 with Bootstrap Res More

€20 EUR in 1 day
(62 Reviews)

Hello, I consider myself appropriate for this project. I am Software Engineer since 2013, I have completed more than 30+ successful mobile apps of iOS and Android. I have also completed more than 25+ successful website More

€23 EUR in 1 day
(20 Reviews)