Page 1 of 1

Help with date calculator

Posted: Wed May 31, 2006 9:04 pm
by michlcamp
trying to calculate between two dates and want to format the form input in the same format as the

Code: Select all

getdate()
function does - so that I can replace $today below with something like: $date_in

my script will take care of the rest if I can config it to use any date input instead of

Code: Select all

$today=getdate()
any/all help appreciated!
thanks in advance.mc

Code: Select all

<?php

//get today's date
$today = getdate();
$month = $today['month'];
$mday = $today['mday'];
$year = $today['year'];
$lyear = $year - 105;

?>

Posted: Thu Jun 01, 2006 10:00 am
by pickle
Not 100% sure what you're asking. Do you want to calculate the time between two dates? How are you getting these two dates - can you generate them yourself or do they come from a form?

Posted: Thu Jun 01, 2006 10:06 am
by michlcamp
this is for an age calculator in a pediatric screening test.

One date ($today) is coded into the form using the getdate() function.
The other I want to come from the form submit.

maybe the faster version of the question is to ask:

how do I convert a form-submitted date from "2006-06-01" to a an array similar to that produced by the getdate() function?

I then have to account for days/weeks premature in order to produce a medically-approved "adjusted age" of child.

hope that clarifies

Posted: Thu Jun 01, 2006 10:14 am
by pickle

Code: Select all

list($year,$month,$day) = explode('-',$value_submitted_from_form);
$form_values = array('year'=>$year,'month'=>$month,$day=>'day');