我正在为Angular datepicker使用KendoUI;为了定义今天的日期,我使用:
public value: Date = new Date();
如果我想将日期显示为今天的日期,减去180天,该怎么办?
这是在typescript / angular 4等中。就像在我的component.ts文件中一样:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-record-filter-from-date',
template: `
<div class="form-group">
<label>From Date:</label>
<kendo-datepicker class="k-widget k-datepicker k-header crowd-control k-input" style="width: 100%;"
[(ngModel)]="value"
[format]="'dd-MMM-yyyy'"
#dateModel="ngModel"
></kendo-datepicker>
</div>
`,
styleUrls: ['./record-filter-from-date.component.css']
})
export class RecordFilterFromDateComponent implements OnInit {
public value: Date = new Date();
constructor() {
}
ngOnInit() {
}
}
答案 0 :(得分:1)
JavaScript类from PIL import Image
out_image = Image.open( StringIO( gs_buck_obj.read_stream() ) )
# run through cloud vision api and do some stuff
....
my_file = StringIO()
out_image.save(my_file , "PNG")
**This is where I am not sure what to do but have tried next line
gs_buck_obj_out.write_stream(my_file.getvalue(), 'text/plain')
可以构建为自1970年1月1日00:00:00 UTC以来的毫秒数,因此您可以像以下一样使用它:
Date
&#13;
构造函数中的180是要减去的天数,let date180DaysAgo = new Date(new Date().getTime() - 180 * 24 * 60 * 60 * 1000);
console.log(date180DaysAgo);
给出180天内的毫秒数
答案 1 :(得分:0)
let today = new Date();
let day = this.today.getDate() - 180;
console.log(day);
答案 2 :(得分:0)
使用Javascript的日期
var date180 = new Date(date.getTime());
date180.setDate(date.getDate() - 180);
答案 3 :(得分:0)
我非常感谢所有人的回复,然而,他们没有按照预期的功能使用KendoUI for Angular。当前未记录的操纵Kendo datePicker对象中日期的方法是:
你需要'addDays'@progress模块:
import { addDays } from '@progress/kendo-date-math';
那么人们可以做数学计算来得到他们期望的日期,在这种情况下:
public value: Date = addDays(new Date(), -180);