unix - Display something in specific day with PHP -


ive got products on site going importat people in specific day, lets products perfect display on valentine's day, of them @ first of april , many products in many other days. question is: how can let site display specific products in specific days?

i think there should way can use unix time in db , every day load script check current unix time unix time in db bit complicated (unix time in second , need specific days not hours or seconds) wonder if there easier way how

pseudo code no specifics given...

first create array/object representing promotions:

 $promos = array(array('product_id' => 566,                   'date' => '12-04'),             array('product_id' => 565,                   'date' => '16-07'),             array('product_id' => 565,                   'date' => '23-07'),             array('product_id' => 565,                   'date' => '22-07'),            ); 

then check current date , query accordingly:

 // todays date $today = date('d-m');  // put items displayed today in $display_today $display_today = array(); foreach($promos $promo){     if($promo['date'] == $today) array_push($display_today, $promo); }  // display somehow foreach($display_today $promo){     // query products id , display } 
  1. you don't have deal database timestamps unless want store promotions in database well.

  2. in practice kind of functionality should extended cover date spans typically valentines day promition last few days before vd ect.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -