반응형
형변환 + 데이터 포맷
import { DatePipe } from '@angular/common';
var datePipe = new DatePipe("en-US");
var date2 = datePipe.transform(new Date(), 'yyyyMMddHHmm'); // 현재 시간 가져와서 date포맷
var result= Number.parseInt(date2); // date를 int로 형변환
1. y represents year.
2. M represents month.
3. d represents day.
4. E represents week day.
5. h represents hour(12).
6. H represents hour(24).
7. m represents minute.
8. s represents seconds.
9. z represents timezone.
Timer
import { Observable } from 'rxjs/Observable';
this.data = new Observable(observer => {
setTimeout(() => {
},1000); // 1초에 실행됨
setTimeout(() => {
observer.complete();
},15000); // 15초에 실행됨.
});
Date Number타입변환
*Date는 Number로 변환해서 시간연산가능
var nowTime = Number(new Date());
반응형