Convert string to date in Swift
How can I convert this string “2016-04-14T10:44:00+0000” into an NSDate and keep only the year, month, day, hour? The T in the middle of it really throws off what I am used to when working with dates. 18 Answers 18
How can I convert this string “2016-04-14T10:44:00+0000” into an NSDate and keep only the year, month, day, hour? The T in the middle of it really throws off what I am used to when working with dates. 18 Answers 18
I want to convert “2014-07-15 06:55:14.198000+00:00” this string date to NSDate in Swift. 18 Answers 18
How do you create a date object from a date in swift xcode. eg in javascript you would do: var day = new Date(‘2014-05-20’); 10 Answers 10
How would I convert an NSString like “01/02/10” (meaning 1st February 2010) into an NSDate? And how could I turn the NSDate back into a string? 17 Answers 17
I am trying to achieve a dropBox sync and need to compare the dates of two files. One is on my dropBox account and one is on my iPhone. I came up with the following, but I get unexpected results. I guess I’m doing something fundamentally wrong when comparing the two dates. I simply used … Read more
I am trying to get the difference between the current date as NSDate() and a date from a PHP time(); call for example: NSDate(timeIntervalSinceReferenceDate: 1417147270). How do I go about getting the difference in time between the two dates. I’d like to have a function that compares the two dates and if(seconds > 60) then … Read more
How do I convert, NSDate to NSString so that only the year in @”yyyy” format is output to the string? 19 Answers 19
How will I convert this datetime from the date? From this: 2016-02-29 12:24:26 to: Feb 29, 2016 So far, this is my code and it returns a nil value: let dateFormatter = NSDateFormatter() dateFormatter.dateFormat = “MM-dd-yyyy” dateFormatter.timeZone = NSTimeZone(name: “UTC”) let date: NSDate? = dateFormatter.dateFromString(“2016-02-29 12:24:26”) print(date) 23 Answers 23
How can I get the year/month/day of a NSDate object, given no other information? I realize that I could probably do this with something similar to this: NSCalendar *cal = [[NSCalendar alloc] init]; NSDateComponents *components = [cal components:0 fromDate:date]; int year = [components year]; int month = [components month]; int day = [components day]; But … Read more
Basically, as the title says. I’m wondering how I could add 1 day to an NSDate. So if it were: 21st February 2011 It would become: 22nd February 2011 Or if it were: 31st December 2011 It would become: 1st January 2012. 30 Answers 30