我有一个我编码的php文件
$xml_time = $update->$node->timestamp; **//Case 1**
$time = date("c",$xml_time);
$normal_time = time(); **//Case 2**
$time = date("c",$normal_time );
Run Code Online (Sandbox Code Playgroud)
$xml_time使用simpleXML从外部xml文件中检索变量.time()在某个早期点使用该函数存储时间.
问题是,当我调用该行$time = date("c",$xml_time);(是案例1)时,我收到一条错误消息,<b>Warning</b>: date() expects parameter 2 to be long, object given in <b>C:\xampp\blah\blah\blah\ajax.php</b> on line <b>46</b><br />但在案例2中,没有出现错误.
任何人都可以帮我识别问题吗?
试试这是否有效:
$xml_time = (integer) $update->$node->timestamp; **//Case 1**
$time = date("c",$xml_time);
Run Code Online (Sandbox Code Playgroud)
这会将SimpleXML对象强制转换为整数.