我试图将输入字符串转换为php的数据对象,以便在sql上使用它,但它不起作用,而且我找不到错误,html是
<div class="form-group ">
<label class="control-label" for="interno">Fecha Limite</label>
<input name="fechalimite" type="datetime-local" class="form-control" id="fechalimite">
</div>
php上的post方法可以做到这一点。
$fecha = getA(strtotime("fechalimite"));
$datetime = date("Y-m-d H:i:s",$fecha);
如果我使用echo fecha显示datetime是正确的,但是$datetime
是空白的,那么我遗漏了什么?
getA
function getA($campo)
{
return(htmlspecialchars(antiinjection($_REQUEST[$campo]), ENT_QUOTES));
}
发布于 2018-07-06 03:37:55
您正在向strtotime()传递一个文字字符串"fechalimite“,它将返回false。
忽略getA函数,只需将请求变量传递给strtotime:
$fecha = strtotime($_REQUEST['fechalimite']);
在将值传递给date()之前,绝对没有理由尝试对HTML实体进行编码。您应该只在生成输出时对实体进行编码。
https://stackoverflow.com/questions/51198635
复制相似问题