php - How to exclude break hours or update timings in regular days and to update working hours during weekend?
Get the solution ↓↓↓I would like to know how to exclude the break hours or update timings from the time dropdown list? And how to set special working hours for Saturday and Sundays?
The output should be like: Monday to Friday 11:30am 12:00 afternoon 12:30pm 13:00pm 13:30pm 14:00pm break hours 17:30pm 18:00pm 18:30pm 19:00pm 19:30pm 20:00pm 20:30pm 21:00pm 21:30pm 22:00pm 22:30pm
Saturday: 12:00 afternoon 12:30pm 13:00pm 13:30pm 14:00pm break hours 17:30pm 18:00pm 18:30pm 19:00pm 19:30pm 20:00pm 20:30pm 21:00pm 21:30pm 22:00pm 22:30pm
Sunday 18:30pm 19:00pm 19:30pm 20:00pm 20:30pm 21:00pm 21:30pm 22:00pm 22:30pm
The Current Code is:
<div class="form-item">
<label for="time"><?php esc_html_e('Zeit', 'cristiano'); ?></label>
<select id="time" name="time" class="required">
<?php
$hours = cs_get_option('reservation_hours');
//Time Loop
//@SEE: http://stackoverflow.com/questions/6530836/php-time-loop-time-one-and-half-of-hour
$time_format = get_option('time_format');
$inc = 15 * 60;
$start = ( strtotime( $hours['from'] ) ); // 11:30 AM
$end = ( strtotime( $hours['to'] ) ); // 10:30 PM
for ( $i = $start; $i <= $end; $i += $inc ) {
// to the standart format
$time = date( $time_format, $i );
$timeValue = date( 'g:ia', $i );
$default = "11:30am";
echo "<option value=\"$timeValue\" " . ( ( $timeValue == $default ) ? ' selected="selected" ' : "" ) . ">$time</option>" . PHP_EOL;
}
?>
</select>
</div>
Thanks!
Help Very much appreciated.
php
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: foreign key constraint is incorrectly formed laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.