【问题标题】:I want to set hour in a date without change the day month and year我想在日期中设置小时而不更改日期月份和年份
【发布时间】:2019-05-23 11:53:21
【问题描述】:

我想将默认小时设置为具有日、月和年的输入日期

在我的 html 组件中我有这个

(dayClicked)="dayClicked($event.day)"

调用我的函数。

在我的 dayClicked 函数中,我想将上午 9:00 小时设置为默认值,而不更改日期 ecc..

【问题讨论】:

    标签: angular typescript


    【解决方案1】:

    现在 $event.day 是什么对象?

    如果是 Date 对象,请执行以下操作:

    const x = new Date(event.value);
    x.setHours(9, 0, 0);
    return x;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-23
      • 1970-01-01
      • 1970-01-01
      • 2017-03-25
      • 1970-01-01
      • 1970-01-01
      • 2018-10-15
      • 2012-01-26
      相关资源
      最近更新 更多