[+] Create function to get year, month, day from date
This commit is contained in:
@@ -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!)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user