0
一直试图设置一些PHP脚本没有任何运气,并希望得到一些关于如何设置它的帮助。哪些文件需要复制以及放置在哪里是我现在的主要问题,所以如果可以的话请帮忙。由于Php商店小时 - 设置
https://github.com/coryetzkorn/php-store-hours
一直试图设置一些PHP脚本没有任何运气,并希望得到一些关于如何设置它的帮助。哪些文件需要复制以及放置在哪里是我现在的主要问题,所以如果可以的话请帮忙。由于Php商店小时 - 设置
https://github.com/coryetzkorn/php-store-hours
只需下载该文件StoreHours.class.php
形式github上,包括要显示商店营业时间在您的文件这个文件..
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>';
就是这样.... :)
由于将尝试立即进行设置。 – SparklingINsilencE
@ SparklingINsilencE是的,让我知道是否有任何问题... –