简体   繁体   English

date_diff()期望参数2为DateTimeInterface,给定字符串

[英]date_diff() expects parameter 2 to be DateTimeInterface, string given

when i am trying to execute this getting error like date_diff() expects parameter 2 to be DateTimeInterface, string given 当我尝试执行此错误时,如date_diff()期望参数2为DateTimeInterface,给定字符串

    $date2=date_create("2017-03-15");
    date_format($date2,"Y/m/d");
    $date1=date('Y/m/d');
    $diff=date_diff($date2,$date1);
    echo $diff;

Both variables should be in the same format. 两个变量应采用相同的格式。 Just try this: 尝试一下:

$date2=date_create("2017-03-15");
$date1=date_create(date('Y-m-d'));
$diff=date_diff($date2,$date1);
echo $diff->days;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 date_diff() 期望参数 1 为 DateTimeInterface,字符串给定 - date_diff() expects parameter 1 to be DateTimeInterface, string given date_diff() 期望参数 2 是 DateTimeInterface,布尔值在第 234 行给出 - date_diff() expects parameter 2 to be DateTimeInterface, boolean given at line 234 Date_diff() 期望参数 2 为 DateTimeInterface,Boolean Given - Date_diff() expects parameter 2 to be DateTimeInterface, Boolean Given DateTime :: diff()期望参数1为DateTimeInterface,给定字符串 - DateTime::diff() expects parameter 1 to be DateTimeInterface, string given 我需要用 PHP 时间戳减去 mySQL 时间戳。 获取“date_diff() 期望参数 1 为 DateTimeInterface,给定数组”错误 - I need to subtract a mySQL timestamp with a PHP timestamp. Getting a “date_diff() expects parameter 1 to be DateTimeInterface, array given” error date_format() 期望参数 1 为 DateTimeInterface,给定布尔值 - date_format() expects parameter 1 to be DateTimeInterface, boolean given PHP date_format()期望参数1为DateTimeInterface - PHP date_format() expects parameter 1 to be DateTimeInterface 检索错误ate_diff()期望参数2为DateTimeInterface - Retrieving error ate_diff() expects parameter 2 to be DateTimeInterface date_format() 期望参数 1 为 DateTimeInterface,给定 null(视图:/home/vagrant/code/blog/resources/views/singlePost.blade.php) - date_format() expects parameter 1 to be DateTimeInterface, null given (View: /home/vagrant/code/blog/resources/views/singlePost.blade.php) 警告:date()期望参数2为long,字符串为 - Warning: date() expects parameter 2 to be long, string given in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM