在Angular中的日期和时间格式化:

huangapple go评论63阅读模式
英文:

date and time format in angular

问题

在将我的记录存储到数据库时,我使用CURRENT_TIMESTAMP来保存createdon列的时间戳。
要检索该时间戳,我使用import java.sql.Timestamp;

DTO: -

private Timestamp createdon;

在我的数据库中,时间戳是2020-08-06 17:28:00.439

我的DTO返回的时间戳是2020-08-06T11:58:00.439+0000,如何以06/08/2020 hours:minutes:seconds的形式显示时间?

英文:

When storing my record in to the database I am using CURRENT_TIMESTAMP to save the createdon column.
To retrieve that timestamp I am using import java.sql.Timestamp;

DTO: -

private Timestamp createdon;

In my database the timestamp is 2020-08-06 17:28:00.439

my DTO is returning Timestamp as 2020-08-06T11:58:00.439+0000, How can I display time as 06/08/2020 hours:minutes:seconds

答案1

得分: 1

你可以使用日期筛选器:

{{createdon | date: 'yyyy/MM/dd HH:mm:ss'}}
英文:

You can use a date filter:

{{createdon | date: 'yyyy/MM/dd HH:mm:ss'}}

答案2

得分: 1

你可以在你的HTML中使用Angular的日期管道:

{{ yourDateValue | date:'M/d/yy, h:mm:ss' }}

更多信息请参考Angular DatePipe

英文:

You can use date pipe of angular in your html

{{ yourDateValue | date:'M/d/yy, h:mm:ss' }}

For more please refer Angular DatePipe

huangapple
  • 本文由 发表于 2020年8月7日 14:42:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/63296552.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定