<?php
include('include/config.php');
$query = "select * from users where user_id='$uid'";
$result = mysqli_query($con,$query)or die(mysqli_error($con));
$fetchRecord = mysqli_fetch_assoc($result);
$c_date = $fetchRecord['create_date'];/*This is date type field in table*/
$date_today = date("Y-m-d");
echo "Table date is =".$c_date;
echo "<br>";
echo "Today date is =".$date_today;
$difference_date = date_diff($c_date,$date_today);
$difference_date->format("%R%a days");
?>
输出给出错误 -
表日期= 2017-12-18
今天的日期是= 2017-12-25
警告:date_diff()期望参数1为DateTimeInterface, 第17行的C:\ xampp \ htdocs \ kmipvt \ 1.php中给出的字符串
致命错误:未捕获错误:调用成员函数格式() C:\ xampp \ htdocs \ kmipvt \ 1.php中的布尔值:18堆栈跟踪:#0 {main} 在第18行的C:\ xampp \ htdocs \ kmipvt \ 1.php中抛出
答案 0 :(得分:0)
尝试添加此内容:
$cn_date = date_create_from_format('Y-m-d', $c_date);
$difference_date = date_diff($cn_date,$date_today);
答案 1 :(得分:0)
你可以试试这个
Who should start first?:Thread 1 or Thread 2
1
Sending elements by First 1
Receiving elements by Second: 1
Sending elements by Second 2
Receiving elements by First: 2
Sending elements by First 90 95 28
Receiving elements by Second: 90 95 28
Who should start first?:Thread 1 or Thread 2
2
Sending elements by Second 1
Receiving elements by First: 1
Sending elements by First 2
Receiving elements by Second: 2
Sending elements by Second 42 10 33
Receiving elements by First: 42 10 33