javascript - 如何将日期格式更改为“dd / mm / yy”?
问题描述
虽然我在javascript中使用'toISOString()',但它记录在照片2中。我如何更改这种格式。
注意:我正在使用 AngularJs。图 1 是list.component.ts
附加文件:
图片1:
formatDate(e) {
var convertDate = new
Date(e.target.value).toISOString().substring(0, 10);
this.studentForm.get('dob').setValue(convertDate, {
onlyself: true
})
}
解决方案
您可以intl
像这样使用 JS 提供的对象 -
const date = new Date();
new Intl.DateTimeFormat('en-GB').format(date);
推荐阅读
- python - 编写一个嵌入式 python 字典到 excel
- c# - 如何使用 DateTime 计算经过的持续时间
- ios - 我可以仅将 WKWebView 用于应用程序构建吗?
- html - 从 Python 和 HTML 中的 MongoDb 列表中获取有关选择的数据
- python - 类型的无效输入:“产品”。先转换为字节、字符串、整数或浮点数
- elasticsearch - 弹性搜索。具有大量映射的单个索引与具有少量映射的多个索引
- google-chrome - 如何在domready之前在webview电子中永久禁用滚动条
- networking - 将 Sharepoint 映射为网络驱动器失去连接
- windows - 拦截或读取 Windows 推送通知
- html - 如何使用 CSS 为 body 和 boder 设置不同的不透明度?