Is there any way to change input type=“date” format?

前端 未结 15 1774
清酒与你
清酒与你 2020-11-21 04:17

I\'m working with HTML5 elements on my webpage. By default input type=\"date\" shows date as YYYY-MM-DD.

The question is, is it possible t

15条回答
  •  粉色の甜心
    2020-11-21 05:06

    i found a way to change format ,its a tricky way, i just changed the appearance of the date input fields using just a CSS code.

    input[type="date"]::-webkit-datetime-edit, input[type="date"]::-webkit-inner-spin-button, input[type="date"]::-webkit-clear-button {
      color: #fff;
      position: relative;
    }
    
    input[type="date"]::-webkit-datetime-edit-year-field{
      position: absolute !important;
      border-left:1px solid #8c8c8c;
      padding: 2px;
      color:#000;
      left: 56px;
    }
    
    input[type="date"]::-webkit-datetime-edit-month-field{
      position: absolute !important;
      border-left:1px solid #8c8c8c;
      padding: 2px;
      color:#000;
      left: 26px;
    }
    
    
    input[type="date"]::-webkit-datetime-edit-day-field{
      position: absolute !important;
      color:#000;
      padding: 2px;
      left: 4px;
      
    }

提交回复
热议问题