반응형
Notice
Link
목록연령대 (1)
스택큐힙리스트
DateTime 형식 생일을 기반으로 누군가의 나이를 계산하는 방법은 무엇인가요?
사람의 생일을 나타내는 DateTime가 주어졌을 때, 그들의 연령을 어떻게 계산할 수 있나요?답변 1이해하기 쉬우며 간단한 해결책입니다. // Save today's date.var today = DateTime.Today;// Calculate the age.var age = today.Year - birthdate.Year;// Go back to the year in which the person was born in case of a leap yearif (birthdate.Date > today.AddYears(-age)) age--;하지만 이는 당신이 서양의 나이 개념을 찾고 있고, East Asian reckoning를 사용하지 않는다는 가정에 따릅니다.답변 2DateTime 타입 생일을 ..
카테고리 없음
2023. 3. 23. 15:37