<?php function getNextBinDay() { // First Wednesday bin day of year //$date = strtotime('2020-01-15 00:00:00'); // Current day (numeric) $day = intval( date('N') ); // Get next Wednesday from today $offset = ($day >= 3) ? 10 - $day : 3 - $day; $nextTimestamp = strtotime( '+' . $offset . ' days' ); $dateText = date( 'l jS F', $nextTimestamp ); // Difference in weeks between dates (86400 * 7) //$diff = ceil( ( $nextTimestamp - $date ) / 604800 ); $firstDate = DateTime::createFromFormat( 'Y-m-d H:i:s', '2020-01-15 02:00:00' ); $secondDate = DateTime::createFromFormat( 'Y-m-d H:i:s', date('Y-m-d 02:00:00', $nextTimestamp) ); $diff = $firstDate->diff($secondDate)->days; $bin = ( $diff % 2 === 0 ) ? 'Blue and Brown' : 'Green'; return 'The next bin day in Chorley woooo is ' . $bin . ' bins on ' . $dateText; } var_dump(getNextBinDay());
You have javascript disabled. You will not be able to edit any code.