我已经回显了一个日期,但它对我来说没有正确的格式,即YMD,我已经在变量中指定了格式,但是当我在回显中将变量称为输入类型的值时,它却没有”给出正确的格式。希望有人帮助我。这是我的代码
<?php
$last_covered=strtotime("+3 Months"); date("Y-m-d", $last_covered);
if ($statusv=='Newly-Registered') echo "<input type='text' class='form-control' name='last_covered' value ='".$last_covered."'>";
答案 0 :(得分:1)
strtotime-将任何英文文本日期时间描述解析为 Unix时间戳
和
date-返回使用给定的整数 timestamp 或当前时间(如果未提供时间戳记)的给定格式字符串格式化的字符串。
因此要同步strtotime()
和date()
,您可以用这种方式做到这一点-
$last_covered=date('Y-m-d',strtotime("+3 Months"));
答案 1 :(得分:0)
您可以尝试
<?php
$last_covered = date("Y-m-d", strtotime("+3 Months"));
if (!empty($statusv) && ($statusv=='Newly-Registered')) {
echo "<input type='text' class='form-control' name='last_covered' value ='".$last_covered."'>";
} else {}
?>
您在回声行上有未定义的变量 可以将变量 $ last_covred 修复为 $ last_covered