php - Show button only from monday to friday -


i have written simple code display button 10am 3pm. works fine this, should not display button on satruday , sunday.

<?php date_default_timezone_set('europe/zurich');  $currenthour = date("h:i"); $day = date(format) $opentime = "10:00"; $closetime = "15:00"; if ($currenthour >= $opentime && $currenthour < $closetime){     $css = 'display:block;'; }else{     $css = 'display:none;'; }  echo '<style type="text/css">.menudelgiorno {'.$css.'}</style>'; ?>  

i'm newbie in programming in general , me lot if can give me tipps. thank you!!

to determine day of week, use formatting option n return iso-8601 numeric representation of day of week (added in php 5.1.0) 1 (for monday) through 7 (for sunday)

$dow = date("n") ; if ($currenthour >= $opentime && $currenthour < $closetime && $dow < 6){     $css = 'display:block;'; }else{     $css = 'display:none;'; } 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -