2018-04-11 05:37
浏览 249

将我的日期选择器格式从(YYYY / MM / DD)更改为(YYYY-MM-DD)

My datepicker format is (YYYY/MM/DD) , my sql only reads (YYYY-MM-DD) format My system only accepts that specific format or the show report wont work properly. Is there anything that i could add , so when i click the specific date the format will be (YYYY-MM-DD)

What should i do please help me. H Thanks

This is my php file

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="//">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src=""></script>
  <script src=""></script>
  $( function() {
    $( "#datepicker" ).datepicker();
  } );

<?php include('session.php'); ?>
<?php include('header.php'); ?>
<div id="wrapper">
<?php include('navbar.php'); ?>
<div style="height:50px;"></div>
<div id="page-wrapper">
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12">

            <h1 class="page-header">Inventory Report</h1>
    <div class="row">
        <div class="col-lg-12">
            <table width="100%" class="table table-striped table-bordered table-hover" id="invTable">

 <form action="total_inventory.php" method="post">
<p>From: <input type="text" class="datepicker" placeholder="E.G.(2018-01-14)" name="dayfrom" required pattern="[0-9]{4}+[0-9]+[0-9]" id="datepicker">
To: <input type="text" class="datepicker" placeholder="E.G.(2018-02-11)" name="dayto" required pattern="[0-9]{4}+[0-9]+[0-9]" id="datepicker1">

  <input type="submit" value="Show Report" name="salesbtn" ></form>


                        <th class="hidden"></th>
                        <th>Product Name</th>

<?php include('script.php'); ?>
<?php include('modal.php'); ?>
<?php include('add_modal.php'); ?>
<script src="custom.js"></script>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • douzi8112 2018-04-11 05:41

    inside the jQuery script code just paste the code.

    $( ".selector" ).datepicker({ 
        dateFormat: 'dd-mm-yy' 

    Note : You can change this format as you required. just edit code as per your requirement.

    点赞 打赏 评论
  • duancong7358 2018-04-11 05:44

    Add the date picker formate in your date picker code like below.

    $( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });

    use the class for all date fields like this: $( ".datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });

    点赞 打赏 评论
  • doulan8846 2018-04-11 05:45

    You can modify through configuration the way you call your datepicker as follows. I see you are using jquery-ui datepicker.

    This should work:

    $( function() {
        $( "#datepicker" ).datepicker({dateFormat: 'yyyy-mm-dd'});

    点赞 打赏 评论

相关推荐 更多相似问题