All pastes #897342 Raw Edit

Something

public text v1 · immutable
·published 2008-02-09 14:07 UTC
rendered paste body
Timelines

                       Jan              Feb              March
Months in the year   |----------------|----------------|----------------|----------------|
Advertisement range     |------------------|
or                                        |----------|
or                                               |------------|
or                                 |----------------------|

So I want to find how many of the days the advertisement range is with february for instance ...

Possible soluition ?

$fromdate = strtotime($pread['fromdate']);
$untildate = strtotime($pread['untildate']) + 86399;	// 86399 is number of seconds in 23:59:59
				
// $fromts = timestamp for start of month
// $tots = timestamp for end of month
// $fromdate = timestamp for beginning of ad period
// $untildate = timestamp for end ofad period

$days = round((min($untildate,$tots) - max($fromdate,$fromts)) / 86400);

The lowest number of $untildate and $tots will be the end of the overlap
the highest number of $fromdate and $fromts will be the start of the overlap