【问题标题】:date function in angular - I want to increment the date by 7 and display in html角度日期函数 - 我想将日期增加 7 并在 html 中显示
【发布时间】:2021-08-31 14:55:07
【问题描述】:

我从 API 31-08-2021 13:58 获得了这种格式的日期 我想在一个 mat-cell 中显示这个日期,然后在另一个 cell 中显示 我必须添加 7 例如:7-09-2021 13:58 并显示这个 如何做到这一点。

【问题讨论】:

标签: angular typescript date-pipe


【解决方案1】:

你可以在你的 ts 文件中做这样的事情。

  date = new Date();
  nextDate = new Date();

  ngOnInit() {
    this.nextDate.setDate(this.date.getDate() + 7);
  }

date - 当前日期(可以是 API 响应中的日期)

nextDate - 日期 + 7 即下一个第 7 天。

【讨论】:

    猜你喜欢
    • 2020-12-21
    • 2020-05-02
    • 2019-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-05
    • 1970-01-01
    相关资源
    最近更新 更多