반응형
DateTimeFormat 옵션을 가져오는 방법
저장하고 싶습니다.DateTimeFormatOptions
위해서date.toLocaleString()
내 앱의 여러 위치에서 사용할 수 있습니다.다음과 같이 정의했습니다.
export const timeFormat = { month: 'numeric', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false, timeZoneName: 'short', time Zone: 'UTC'}
그리고 저는 다음을 얻습니다.
Argument of type '{ month: string; day: string; hour: string; minute: string; hour12: boolean; timeZoneName: string; timeZone: string; }' is not assignable to parameter of type 'DateTimeFormatOptions'.
Types of property 'month' are incompatible.
Type 'string' is not assignable to type '"numeric" | "2-digit" | "short" | "long" | "narrow" | undefined'.
그러나 ImportDateTimeFormatOptions를 찾을 수 없습니다.결국 저는 날짜 형식을 지정하는 도우미 메소드를 작성했지만, 사용자가 날짜 환경설정을 변경하도록 허용할 수 있기 때문에 가져올 필요가 있을 수 있습니다.
그것은 물건 안에 있습니다.수입할 필요가 없습니다.유형을 다음으로 설정합니다.Intl.DateTimeFormatOptions
.
const timeFormat: Intl.DateTimeFormatOptions = { month: 'numeric', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false, timeZoneName: 'short', timeZone: 'UTC' }
언급URL : https://stackoverflow.com/questions/71757346/how-to-import-datetimeformatoptions-in
반응형
'programing' 카테고리의 다른 글
*(uint32_t*) 식을 이해하지 못함 (0) | 2023.06.11 |
---|---|
문자열을 16진수 바이트로 인쇄 (0) | 2023.06.11 |
Oracle에서 임시 테이블과 글로벌 임시 테이블의 차이점은 무엇입니까? (0) | 2023.06.11 |
JavaScript를 사용한 ASP.NET 포스트백 (0) | 2023.06.11 |
WebAPI 컨트롤러에서 작업을 찾을 수 없습니다. (0) | 2023.06.11 |