<?php
$frequency = 'weekly';
// If its daily we only run the cron once a day so send
if ($frequency === 'daily') {
return true;
}
try {
$startDate = new DateTime('2014-11-15 00:00:00');
$now = new DateTime(2014-11-22 00:00:00);
// Get the diff between the two dates
$diff = $now->diff($startDate);
if ($frequency === 'weekly') {
$daysDiff = (int) $diff->format('%d');
echo $daysDiff % 7 === 0
? 'true'
: 'false';
} else {
$monthDiff = explode(',', $diff->format('&m,%d'));
if ($monthDiff[0] > 0 && $monthDiff[1] != 0) {
echo 'true';
}
}
} catch (Exception $e) {
// TODO: Better error handling ... Log it :)
return false;
}