简体   繁体   English

日期格式角度和打字稿的转换

[英]conversion of date format angular and typescript

How can I convert 我该如何转换

Sun Apr 08 1979 00:00:00 GMT+0800 (Malay Peninsula Standard Time) 

to YYYY-MM-DD[T]HH:mm:ss , but in the date data type not the string data type? YYYY-MM-DD[T]HH:mm:ss ,但是在日期数据类型中不是字符串数据类型? I'm having difficulty in changing this, as it is converted to string format using moment. 我很难更改此设置,因为它会使用一下矩转换为字符串格式。

Pass your string to Date, Like this way 将您的字符串传递给Date,就像这样

In componet: 在竞争中:

newdate = new Date('Sun Apr 08 1979 00:00:00 GMT+0800');

In Html: 在HTML中:

<p>Formatted Date: <b>{{ newdate | date:'yyyy-MM-dd[T]HH:mm:ss' }}</b> </p>

Demo: 演示:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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