0

我正在使用这个名为 showtime 的插件。我喜欢它,但有一个问题,我想调用当天的日程安排。该插件的某些部分要求使用简码来获取所有日期和那些日子的日程安排。

我在下面的代码中添加了什么以确保它获得当天的时间表。

function showtime_schedule_handler($atts, $content=null, $code=""){

global $wpdb;
global $showtimeTable;

//Get the current schedule, divided into days
$daysOfTheWeek = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

$schedule = array();

$output = '';

foreach ($daysOfTheWeek as $day) {
    //Add this day's shows HTML to the $output array
    $showsForThisDay =  $wpdb->get_results( $wpdb->prepare ( "SELECT * FROM $showtimeTable WHERE dayOfTheWeek = '$day' ORDER BY startTime" ));
4

1 回答 1

1

我认为使用时间功能来解决问题。

<?php
$nextWeek = time() + (7 * 24 * 60 * 60);
                   // 7 days; 24 hours; 60 mins; 60secs
echo 'Now:       '. date('Y-m-d') ."\n";
echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n";
// or using strtotime():
echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."\n";
?>

上面的示例将输出类似于:

现在:2005-03-30 下周:2005-04-06 下周:2005-04-06

于 2013-01-14T08:01:09.710 回答