输入type =“ date”如何格式化?

时间:2018-09-25 08:34:13

标签: php angular-ngmodel

我正在使用输入.navbar-nav > li{ padding-left:10px; padding-right:10px; font-size: 15px; } .dropdown > .dropdown-menu { min-width: 570px; margin-top: 8px; } .multi-column-dropdown { list-style: none; margin-left: 20px; padding: 0px; } .multi-column-dropdown li a { display: block; clear: both; line-height: 1.428571429; color: rgb(0, 0, 0); white-space: normal; margin-top: 10px; } .multi-column-dropdown li a:hover { text-decoration: none; color: #f80606; } @media (max-width: 767px) { .dropdown-menu.multi-column { min-width: 240px !important; overflow-x: hidden; } },但它总是以这种格式保存到数据库中。

  

2018年9月25日星期二00:00:00 GMT + 0800(菲律宾标准时间)

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<nav class="navbar navbar-nav navbar-expand-md navbar-light bg-white 
sticky-top ">
<div class="container">
  <a href="index.php" class="navbar-brand "><img src="images/Logo.png" width="200" height="60"></a><button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsenavbar">
  <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="collapsenavbar">
     <ul class="navbar-nav ml-auto">
        <li class="nav-item active">
           <a class="nav-link font-weight-bold" href="index.php">Home</a>
        </li>
        <li class="nav-item dropdown">
           <a class="nav-link dropdown-toggle font-weight-bold" href="#" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Services</a>
           <div class="dropdown-menu multi-column" aria-labelledby="dropdown01">
              <div class="row">
                 <div class="col-md-3 col-sm-3 col-lg-3">
                    <ul class="multi-column-dropdown">
                       <li><a href="caterers.php">Caterers</a></li>
                       <hr />
                       <li><a href="decorer.php">Decorator</a></li>
                       <hr />
                       <li><a href="dholwale.php">Dhol Wale</a></li>
                       <hr />
                    </ul>
                 </div>
                 <div class="col-md-3 col-sm-3 col-lg-3">
                    <ul class="multi-column-dropdown">
                       <li><a href="flowrdecor.php">Flower Decorator</a></li>
                       <hr />
                       <li><a href="makeupart.php">Makeup Artist</a></li>
                       <hr />
                       <li><a href="mehandi.php">Mehandi Artist</a></li>
                       <hr />
                    </ul>
                 </div>
                 <div class="col-md-3 col-sm-3 col-lg-3">
                    <ul class="multi-column-dropdown">
                       <li><a href="photo.php">Photography</a></li>
                       <hr />
                       <li><a href="sound.php">Sound & DJ</a></li>
                       <hr />
                       <li><a href="Venue_1.php">Venue</a></li>
                       <hr />
                    </ul>
                 </div>
                 <div class="col-md-3 col-sm-3 col-lg-3">
                    <ul class="multi-column-dropdown">
                       <li><a href="cards.php">Wedding Cards</a></li>
                       <hr />
                       <li><a href="Wedplan.php">Wedding Planner</a></li>
                       <hr />
                    </ul>
                 </div>
              </div>
           </div>
        </li>
     </ul>
  </div>

如何设置仅像type="date"这样的格式? 预先谢谢你。

3 个答案:

答案 0 :(得分:0)

您不能为此原生HTML输入指定格式。

尝试使用DateTimePicker

答案 1 :(得分:0)

我不会-如果您需要在数据库中进行任何计算,则需要采用数据库可以理解的格式。

听起来您真正想要的是以某种格式显示日期的日期,在这种情况下,您可以使用PHP或Moment.js之类的JavaScript库来执行此操作。

答案 2 :(得分:0)

PHP中有函数date()。 您可以的话

$unformatted = "Tue Sep 25 2018 00:00:00 GMT+0800";
$formatted = date("m/d/Y", strtotime($unformatted));

注意:大多数数据库都需要您设置日期格式:

Y-m-d         //for date
Y-m-d H:i:s   //for datetime