gpt4 book ai didi

javascript - 如何在每个浏览器(包括手机)中启用类型 =“date”

转载 作者:行者123 更新时间:2023-12-03 10:17:00 28 4
gpt4 key购买 nike

我对日期有一个大问题,<input type="date">不适用于 Mozilla Firefox,但适用于 IOS、Windows Phone 和其他浏览器。

是否可以在 Mozilla Firefox 中修复此问题并将日期格式设置为 dd-mm-yyyy

最佳答案

我在 FireFox 中使用日期输入。不要紧。提交表单后,我仍然在提交日期使用 strtotime()

$date = strtotime ($_POST['date']);
<小时/>

我有一个 PHP 脚本,可以计算两个日期之间的天数。

两个日期之间的天数

此图片来自 FireFox:
Days Between Two Dates

<?php
$to = strtotime($_GET['to']);
$from = strtotime($_GET['from']);
if (!$from && !$to){
$from = '8/21/2001';
$to = '5/27/2014';
$answer = "<h2>Number of days between<br/>Tuesday the 21st of August 2001 and<br/>Tuesday the 27th of May 2014 is<br/>4,662 days</h2>";
}
else {
$days = number_format(intval(($to - $from) / 86400));
$d1 = date('l \t\h\e jS \of F Y ',$from);
$d2 = date('l \t\h\e jS \of F Y ',$to);
$answer = "<h2>Number of days between<br/>$d1 and<br/>$d2 is<br/>$days days</h2>";
$to = $_GET['to'];
$from = $_GET['from'];
}
echo <<<EOT
<form method="get" action-"dates2days.php">
From: <input type="date" name="from" value="$from"/><br/>
To:&emsp;&ensp;<input type="date" name="to" value="$to" /><br/>
<input type="submit" value="&emsp;Get Days Between Dates&emsp;"/>
$answer
</form>
EOT;
?>

关于javascript - 如何在每个浏览器(包括手机)中启用类型 =“date”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29830168/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com