Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 警告:DateTime::setTimestamp()要求参数1很长_Php_Wordpress_Datetime_Timestamp - Fatal编程技术网

Php 警告:DateTime::setTimestamp()要求参数1很长

Php 警告:DateTime::setTimestamp()要求参数1很长,php,wordpress,datetime,timestamp,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->s

我是新来的,很抱歉,如果我提出的问题不正确。。。但我得到了这个错误:

警告: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));

我希望有人能帮我,我已经搜索了所有的谷歌搜索,没有发现任何有用的,谢谢

请提供函数get\u post\u meta的代码。它似乎并不(总是)返回一个数值。
get\u post\u meta($a->ID,''u jfc\u end\u time',true)
部分的例子是什么?函数setTimestamp需要一个数字(UNIX timestamp),所以我猜测它被赋予了一个字符串或NULL。我对PHP几乎是个新手,我正在尝试浏览其他人的代码。是否有办法查看返回的
get\u post\u meta
是什么?请提供函数get\u post\u meta的代码。它似乎并不(总是)返回一个数值。
get\u post\u meta($a->ID,''u jfc\u end\u time',true)
部分的例子是什么?函数setTimestamp需要一个数字(UNIX timestamp),所以我猜测它被赋予了一个字符串或NULL。我对PHP几乎是个新手,我正在尝试浏览其他人的代码。有没有办法查看
get\u post\u meta
返回的内容?