我正在使用CI并且它成功地回应了正确的过期日期,但我也收到了此错误:
遇到非正确形成的数值
$expire_datetime = date('g:ia \o\n l jS F Y',strtotime($row->created, "+2weeks"));
echo $expire_datetime;
答案 0 :(得分:0)
所有编码都是正确的。问题出在+2weeks
。使用strtotime()
功能时,您需要在文字<space>
之间保留(+2<SPACE>weeks)
。
实施例(from W3Schools)
<?php
echo(strtotime("now") . "<br>");
echo(strtotime("3 October 2005") . "<br>");
echo(strtotime("+5 hours") . "<br>");
echo(strtotime("+1 week") . "<br>");
echo(strtotime("+1 week 3 days 7 hours 5 seconds") . "<br>");
echo(strtotime("next Monday") . "<br>");
echo(strtotime("last Sunday"));
?>
所以你的Final Well表单代码是
$expire_datetime = date('g:ia \o\n l jS F Y',strtotime($row->created, "+2 weeks"));
答案 1 :(得分:0)
strtotime()
函数需要在第一个参数中使用相对日期格式。第二个参数是可选的,可以是unix时间戳。