我在服務器中使用 java spring-boot 并Instant.now()用于填充Instant日期變量。在我的客戶中,我想顯示日期,但其格式UTC如下所示:"date": "2018-09-11T11:16:27.708783700Z"我在我的客戶端上使用NativeScript和Angular我應該如何在我的客戶端上格式化這個日期?
2 回答

湖上湖
TA貢獻2003條經驗 獲得超2個贊
對于客戶端,您可以使用 angular datepipe API 使其可讀日期。否則你也可以使用moment。下面是示例
@Component({
selector: 'date-pipe',
template: `<div>
<p>Today is {{today | date}}</p>
<p>Or if you prefer, {{today | date:'fullDate'}}</p>
<p>The time is {{today | date:'h:mm a z'}}</p>
</div>`
})
// Get the current date and time as a date-time value.
export class DatePipeComponent {
today: number = Date.now();
}
你可以在這里查看他們的文檔
添加回答
舉報
0/150
提交
取消