Calcetines Extreme

Calcetines Extreme
Take care of you using the best socks

Monday, December 8, 2014

Change banner rotation each day

Our customer need to change the banner exposition to a different one each day, we only have 2 banner options soo, we only need to show a different banner each day.


To do that, i think on read the day of current date, divide by 2 it and get the rest part of the division. If the rest part is nan then show banner A, else show banner B.

' Reading current date
$date = date("ymd");

' Get current day number
$day_number = date('n', strtotime($date));

' divide it by 2
$res = substr($date, 4, 2) %2 ;

' final condition
if ($res==0){ 'show banner a }else{ 'show banner b }