I am using code along these lines:
$start = date_create(1990-10-01); $end = new DateTime(); $diff = date_diff($start, $end); $trading = $diff->format("%y")
to calculate how long a company has been trading. Works well.
I am using a PHP framework which separates framework (generic) code from project-specific code. I would like to adjust this code so that it exists within the framework code and all I need in the project-specific code is a value I can code once (start_date) which I can send to this code (in a function say) and I need the result to be available easily from every page in the site (not just a master page but individual pages) which I can include with a short and simple span.
How to do this?
I’m guessing I put this code inside a function and replace the hard-coded start_date with a passed in value from the project specific side and have it return the value???
Not sure how to store the variable to pass in once? Constant?
Not sure how I would then call/use it a span?