警告:DateTime :: setTimestamp()期望参数1为long

时间:2015-12-16 17:19:15

标签: php wordpress datetime timestamp

我是新来的,很抱歉,如果我错误地提出这个问题......但我收到了这个错误:

警告:DateTime :: setTimestamp()期望参数1为长

对于此代码:

if(!function_exists('sort_posts_by_time')) {
function sort_posts_by_time($a, $b) {

    // set the times from the meta values
    $time_a = new DateTime();
    $time_a->setTimestamp(get_post_meta($a->ID, '_jfc_start_date', true));
    if($start_time_a = get_post_meta($a->ID, '_jfc_start_time', true)) {
        $time_a->modify($start_time_a);
    }

    $time_b = new DateTime();
    $time_b->setTimestamp(get_post_meta($b->ID, '_jfc_start_date', true));
    if($start_time_b = get_post_meta($b->ID, '_jfc_start_time', true)) {
        $time_b->modify($start_time_b);
    }

    if($time_a == $time_b) {

        $time_a->setTimestamp(get_post_meta($a->ID, '_jfc_end_time', true));

        $time_b->setTimestamp(get_post_meta($b->ID, '_jfc_end_time', true));

    }

    return ($time_a->getTimestamp() > $time_b->getTimestamp()) ? 1 : -1;
}

}

错误特别发生在上面的代码中,这里:

$time_a->setTimestamp(get_post_meta($a->ID, '_jfc_end_time', true));

$time_b->setTimestamp(get_post_meta($b->ID, '_jfc_end_time', true));

我希望有人可以帮助我,我已经遍布谷歌搜索并且找不到任何有用的东西,谢谢!

0 个答案:

没有答案