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

时间:2015-04-23 17:11:48

标签: javascript html5

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

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

1 个答案:

答案 0 :(得分:1)

我在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;
?>