我一直在尝试在下面设置一些php脚本,但没有任何运气,希望能为如何设置它提供一些帮助。复制哪个文件以及放在哪里是我现在的主要问题,所以如果可以的话,请帮忙。感谢
https://github.com/coryetzkorn/php-store-hours
只需从github下载文件StoreHours.class.php
,并将该文件包含在您想要显示营业时间的文件中。。
include('StoreHours.class.php');
现在设置date_default_timezone_set('America/New_York');
定义每日开放时间
// Must be in 24-hour format, separated by dash
// If closed for the day, leave blank (ex. sunday)
// If open multiple times in one day, enter time ranges separated by a comma
$hours = array(
'mon' => array('11:00-20:30'),
'tue' => array('11:00-13:00', '18:00-20:30'),
'wed' => array('11:00-20:30'),
'thu' => array('11:00-1:30'), // Open late
'fri' => array('11:00-20:30'),
'sat' => array('11:00-20:00'),
'sun' => array() // Closed all day
);
添加异常天数(可选)
// Add exceptions (great for holidays etc.)
// MUST be in a format month/day[/year] or [year-]month-day
// Do not include the year if the exception repeats annually
$exceptions = array(
'2/24' => array('11:00-18:00'),
'10/18' => array('11:00-16:00', '18:00-20:30')
);
将模板消息设置为显示
// Place HTML for output below. This is what will show in the browser.
// Use {%hours%} shortcode to add dynamic times to your open or closed message.
$template = array(
'open' => "Yes, we're open! Today's hours are {%hours%}.",
'closed' => "Sorry, we're closed. Today's hours are {%hours%}.",
'closed_all_day' => "Sorry, we're closed today.",
'separator' => " - ",
'join' => " and ",
'format' => "g:ia", // options listed here: http://php.net/manual/en/function.date.php
'hours' => "{%open%}{%separator%}{%closed%}"
);
启动课堂存储时间
$store_hours = new StoreHours($hours, $exceptions, $template);
调用呈现方法以输出打开/关闭的消息
$store_hours->render();
显示完整的开放时间列表(一周)
echo '<table>';
foreach ($store_hours->hours_this_week() as $days => $hours) {
echo '<tr>';
echo '<td>' . $days . '</td>';
echo '<td>' . $hours . '</td>';
echo '</tr>';
}
echo '</table>';
就是这样……:)