[+] Create function to get year, month, day from date

This commit is contained in:
Hykilpikonna
2021-01-17 13:48:17 -05:00
parent 650c48ade9
commit 395a7ecdec
+8
View File
@@ -16,4 +16,12 @@ extension Date
f.dateFormat = "yyyy-MM-dd hh:mm:ss"
return f.string(from: self)
}
/// Get year, month, day
func getYMD() -> (y: Int, m: Int, d: Int)
{
let calendar = Calendar.current
let comp = calendar.dateComponents([.year, .month, .day], from: self)
return (comp.year!, comp.month!, comp.day!)
}
}