tags:

views:

64

answers:

3

Hi I have already asked a similar question. but want to make a change like this:

I have a starting date and ending date called into a function in php. I need to estrapolate the stating day and month form the startingDate and the same for the endingDate, so to make calculation based on day and month.

How do I go about this? Thank you thank you thank you. Francesco

A: 

$start_month = date('m',$inStart); $start_day = date('d',$inStart);

$end_month = date('m',$inEnd); $end_day = date('d',$inEnd);

Justin
A: 

Have a look at the diff method of the DateTime object build into PHP. Presuming you can turn startingDate and endingDate into DateTime objects (perhaps they already are), this will give you what you're looking for.

Ed Carrel
A: 

You could always break down the current date into a timestamp;

list($s_y, $s_m, $s_d) = explode('/', $start_date); $start_date_ts = mktime(12, 12, 12, $s_m, $s_d, $s_y);

list($e_y, $e_m, $e_d) = explode('/', $end_date); $end_date_ts = mktime(12, 12, 12, $e_m, $e_d, $e_y);

Then you'll have $end_date_ts and $start_date_ts, which you can compare and represent with ease.

Mattze