$startDate = substr_replace($field['sql_name'], 'start_date', -11, -1);
$endDate = substr_replace($field['sql_name'], 'end_date', -11, -1);
$isActive = substr_replace($field['sql_name'], 'is_active', -11, -1);
- $todayStart = date('Ymd', strtotime('now'));
- $todayEnd = date('Ymd', strtotime('now'));
- return "IF($isActive = 1 AND ($startDate <= '$todayStart' OR $startDate IS NULL) AND ($endDate >= '$todayEnd' OR $endDate IS NULL), '1', '0')";
+ $today = date('Ymd');
+ return "IF($isActive = 1 AND ($startDate <= '$today' OR $startDate IS NULL) AND ($endDate >= '$today' OR $endDate IS NULL), '1', '0')";
}
/**
*/
public static function renderNonExpiredSql(array $field): string {
$endDate = substr_replace($field['sql_name'], 'expires_date', -11, -1);
- $todayEnd = date('Ymd');
- return "IF($endDate >= '$todayEnd' OR $endDate IS NULL, 1, 0)";
+ $today = date('Ymd');
+ return "IF($endDate >= '$today' OR $endDate IS NULL, 1, 0)";
}
}