简体   繁体   中英

I am trying date format mm/dd/yyyy to dd/mm/yyyy in input type date

This is my code

 <input type="date" class="form-control float-right" value="dd-mm-yyyy" name="from_date_bk" id="from_date_bk">

And it returns like this 在此处输入图片说明

I want dd/mm/yyyy format

Suppose your date is 2019-01-15

var date = "2019-01-15";
var d = new Date(date);

var month = d.getMonth()+1;
var day = d.getDate();

var output = (day<10 ? '0' : '') + day +'-'+ (month<10 ? '0' : '') + month + '-' +d.getFullYear();

Result

15-01-2019

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM