Created
May 23, 2017 07:50
-
-
Save emre-yilmaz/07bfa901b442a9308317bbdfbad680f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func addOneDay () -> String { | |
| //var dateString = "2014-01-12" | |
| let dateFormatter = DateFormatter() | |
| dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss +zzzz" | |
| // let s = dateFormatter.date(from: stringDate) | |
| // print(s) | |
| let s = Date() | |
| let calendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier(rawValue: NSGregorianCalendar)) | |
| let dateComponent = NSDateComponents() | |
| dateComponent.day = 1 | |
| //var newDate = calendar?.date(byAdding: dateComponent as DateComponents, to: s!, options: nil) | |
| let newDate = calendar?.date(byAdding: dateComponent as DateComponents, to: s, options: []) | |
| let dateString = dateFormatter.string(from: newDate!) | |
| return dateString | |
| } | |
| func nowTime() -> String { | |
| let nowDate = Date() | |
| let dateFormatter = DateFormatter() | |
| dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss +zzzz" | |
| let dateString = dateFormatter.string(from: nowDate) | |
| return dateString | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment