Angular ABP中的DateTimePicker字段
Angular DateTimePicker field in ABP
我有一个应该只显示时间的 DateTime 字段:
HTML:
<div class='input-group date'>
<input class="form-control" type="datetime" #RequiredByDate name="RequiredByDate" [value]="formatDate(hitchRequest.requiredByDate, 'LT')" required>
<span class="input-group-addon">
<span class="fa fa-clock-o"></span>
</span>
</div>
TS:
formatDate(date: any, format: string): string {
if (!date) {
return '';
}
return moment(date).format(format);
}
onShown(): void {
$(this.requiredByDate.nativeElement).datetimepicker({
locale: abp.localization.currentLanguage.name,
format: 'LT',
});
}
它在页面加载时正确显示值,但每次我点击保存按钮时,都会将随机时间设置为要发送到服务器的对象!日期部分没问题!
好吧,由于我所在的时区,它增加了 10:30 小时。诀窍在于 back-end 将输入的日期与今天的日期和时间进行比较时,我必须使用 Clock.Now
而不是 DateTime.Now
.
我有一个应该只显示时间的 DateTime 字段:
HTML:
<div class='input-group date'>
<input class="form-control" type="datetime" #RequiredByDate name="RequiredByDate" [value]="formatDate(hitchRequest.requiredByDate, 'LT')" required>
<span class="input-group-addon">
<span class="fa fa-clock-o"></span>
</span>
</div>
TS:
formatDate(date: any, format: string): string {
if (!date) {
return '';
}
return moment(date).format(format);
}
onShown(): void {
$(this.requiredByDate.nativeElement).datetimepicker({
locale: abp.localization.currentLanguage.name,
format: 'LT',
});
}
它在页面加载时正确显示值,但每次我点击保存按钮时,都会将随机时间设置为要发送到服务器的对象!日期部分没问题!
好吧,由于我所在的时区,它增加了 10:30 小时。诀窍在于 back-end 将输入的日期与今天的日期和时间进行比较时,我必须使用 Clock.Now
而不是 DateTime.Now
.