将获取当前日期添加到此脚本?

时间:2013-01-14 07:55:25

标签: php plugins

我正在使用这个名为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" ));

1 个答案:

答案 0 :(得分: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