如何将datatime本地输入转换为php变量?
我试图将输入字符串转换为php的数据对象,以便在sql上使用它,但它不起作用,而且我找不到错误,html是如何将datatime本地输入转换为php变量?,php,Php,我试图将输入字符串转换为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="fech
<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>
如果我使用echo-fecha正确显示日期时间,但$datetime
只是空白,我缺少什么
getA
function getA($campo)
{
return(htmlspecialchars(antiinjection($_REQUEST[$campo]), ENT_QUOTES));
}
您正在向strotime()传递一个文本字符串“fecharimite”,该字符串将返回false 忽略getA函数,只需将请求变量传递给strottime:
$fecha = strtotime($_REQUEST['fechalimite']);
在将值传递给date()之前,绝对没有理由尝试对HTML实体进行编码。您应该仅在生成输出时对实体进行编码。这是错误的,它将字符串传递给
strotime()
试一试
尽管看起来您正在使用getA
作为反SQL注入机制
最好对此使用参数化绑定查询
我们可以问一下getA()函数getA($campo){return(htmlspecialchars(antiinjection($\u REQUEST[$campo]),entu QUOTES))在做什么吗?}请提供更多细节,“它不起作用”不是很好的描述。
$datetime
的内容是什么之后,有没有错误消息(启用了所有错误:)?我说$datetime是空白的打印($fecha)代码>并告诉我们它包含什么
$fecha = strtotime($_REQUEST['fechalimite']);
$fecha = getA(strtotime("fechalimite"));
$fecha = strtotime(getA("fechalimite"));