输入类型日期从另一个位置获取日期

input type date getting date from another location

我有一个日期类型的输入,在某些计算机上它 return 是 dd/MM/yyyy 格式的日期,但在其他计算机上 return 是 [=16] 格式的日期=],我希望它 return 仅格式 dd/MM/yyyy 巴西模式

                        <div class="input-group input-group text-center input-cep w-mmd-50 input-date">
                            <input formControlName="data" type="date" min="{{today}}" class="form-control"
                            id="inputData"  >
                       </div>

有没有办法只用 HTML 或 javascript 或 angular 管道来做到这一点? 我没有找到任何关于它的信息,我搜索了一下,它说它会根据语言环境或浏览器发生变化

您从 input type="date" 获得的默认日期值采用 (yyyy-mm-dd) 格式,您需要将其更改为您的要求。作为参考,您可以查看 here

function myDateFormat() {

var dateControl = document.querySelector('input[type="date"]');
console.log(dateControl.value);
const [year, month, day] = dateControl.value.split('-');

const result = [day, month, year].join('/');
document.getElementById("showDate").innerHTML = result;

}
#showDate {
margin-top:10px;
}
<input type="date" onchange="myDateFormat()">
<div id="showDate"></div>

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date[粗体我]

Note: The displayed date format will differ from the actual value — the displayed date is formatted based on the locale of the user's browser, but the parsed value is always formatted yyyy-mm-dd.

换句话说,您可以让浏览器决定格式,因为这将取决于用户是否适合国际消费。