와 나는 현재 내가 DateFormatter.dateFormat을 사용하고 스위프트 3. 와 라벨에 현재 날짜를 표시하는 방법을 찾고 있어요하지만 내가 할 수있는 유일한 출력은표시 날짜 DateFormatter
코드의 라인 :DD입니다. MM.yyyy 여기
lbl_Date.text = DateFormatter.dateFormat(fromTemplate: "MMddyyyy", options: 0, locale: NSLocale(localeIdentifier: "de-AT") as Locale)
는 그리고 오늘 내 예상 출력은 다음과 같아야합니다
2016년 11월 12일
나는 내가 dateTimeComponents와 시간을 얻을 수 있다는 것을 알고 있지만 나는 내 라벨에 날짜 만 (일, 월, 년)를 얻을 수있는 방법을 생각하지 않은 :
// get the current date and time
let currentDateTime = Date()
// get the user's calendar
let userCalendar = Calendar.current
// choose which date and time components are needed
let requestedComponents: Set<Calendar.Component> = [
.year,
.month,
.day,
.hour,
.minute,
.second
]
// get the components
let dateTimeComponents = userCalendar.dateComponents(requestedComponents, from: currentDateTime)
라벨에 현재 날짜를 가장 깨끗하게 표시하는 방법은 무엇입니까?
이 기능은 날짜 형식을 만드는 것입니다. 그런 다음 그 문자열을 사용하여 날짜를 문자열로 렌더링합니다. 방법을 찾으려면 스택 오버플로에 대한 이와 유사한 질문을 살펴보십시오. – Fogmeister
[NSDate를 NSString으로 변환] 가능한 복제본 (http://stackoverflow.com/questions/576265/convert-nsdate-to-nsstring) – Fogmeister