我想问一下如何使用PHP将格式 YYYYMMDD 的日期输入到txt文件? 这里是我的代码,但我可以使用文本输入它而不是日期格式:
<a> From : </a> // to show date after input
<?php // to show date after input
echo file_get_contents(from.txt" ); // to show date after input
?> // to show date after input
<?php
$file = "/var/www/html/from.txt";
if(isset($_POST))
{
$postedHTML = $_POST['html'];
file_put_contents($file, $postedHTML);
}
?>
<form action="" method="post">
<?php
$content = file_get_contents($file);
echo "<textarea name='html'>" . htmlspecialchars($content) . "</textarea>";
?>
<input type="submit" value="Click to enter date" />
</form>
答案 0 :(得分:1)
你试试这个:
<form action="" method="post">
<?php
$date = htmlspecialchars($content)
$display_date= date("Y-m-d", strtotime($date));
echo "<input type='date' name='html' value ='" . $display_date . "'>";
?>
<input type="submit" value="Click to enter date" />
</form>
答案 1 :(得分:0)
尝试这样:
<form action="" method="post">
<?php
$content = file_get_contents($file);
echo"<input type='date' name='date'>";
?>
<input type="submit" value="Click to enter date" />
</form>