Time interval for NSDate

I work with API and I need to convert NSInterval to date. For example, I have NSNumber model.complaintCreatedTime = 1480550400000.I try this method, but it doesn't work: NSDate* date = [NSDate dateWithTimeIntervalSinceReferenceDate :[(NSString *)mode

How to change the current hours and minutes (Swift 2)

If I create an NSDate() to get the current date and time, and I want to create a new date from that but with different hour, minute, and zero seconds, what's the easiest way to do it using Swift 2? I've been finding so many examples with 'getting' bu

deactivate the button

I have some 6 UILabels which will show the date like below: Jan,2016 (label) (button) < **27Dec 28Dec 29Dec 30Dec 31Dec 1Jan** >(Button) Also I am having two arrow UIButton at both side when user can move to back date or previous date. And i have on

Create an event that runs every 24 hours?

I have a Swift data file in the "Quote a Day" project with 500 quotes and I would like to call updateQuote() every time it becomes a new day. The quote string variable updates a UILabel in the QuoteViewcontroller and the string for the alertBody

iOS NSDateFormatter needs NSLocale even if it's UTC

I have a doubt that I cannot understand why is the way it is and I appeal to the Gods of this site :) I have a date coming like this: "1982-01-01T00:00:00Z" As I'm displaying whatever the server sends (I know, customer requirement, not good prac

NSDate formatter iOS and TimeAgo with server parse.com

I try get a date of string: NSLog(@"DATE: %@", obj[@"createdAt"]); NSDateFormatter* formatter = [[NSDateFormatter alloc]init]; formatter.dateFormat = @"YYYY'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'"; NSLocale *locale = [[NSLocale al

Compare the month and day of two NSDates

I need to setup an if/else statement that compares only the month and day of two NSDates. One of the dates is selected with a UIDatePicker and the other would be today's date. If the month and date of the two are the same, something happens, if not s

Swift compares the day of the week of a date with an int

I have a UIDatePicker wich needs to gets validated. I want to check if the weekday from the UIDatePicker is a specific int value. I use @IBAction func validateDateTime(sender: AnyObject) { var date = self.dateTime.date let formatterWeekday = NSDateFo

How do I add the current time (HH: MM: SS) to NSDate?

I am using https://github.com/ruslanskorb/RSDayFlow to add calendar to my application. I override the method as // Prints out the selected date. - (void)datePickerView:(RSDFDatePickerView *)view didSelectDate:(NSDate *)date { self.transactionDate = d

Convert string to NSDate in Swift

How to convert this date to NSDate datestring = /Date(147410000000)/ //String from server response Expected Output: 12/01/2014 I tried this. But I got nil. let dateFormatter:NSDateFormatter = NSDateFormatter() dateFormatter.dateFormat = "dd/MM/yyyy&q

Convert NSDate to NSstring

Hi I m pick the date from UIDatePicker and convert it in NSstring.. All the date working fine. Hi have set maximum date as 2001-12-31. When i choose this date the string return as "2002-12-31" dOBPicker = [[UIDatePicker alloc]initWithFrame:CGRec

Define the application to use UTC globally

How can I for an IOS app from code default to use UTC as the default timezone. In other words, if anywhere from my app I initialize an NSDate, I want to it to be using UTC as the timezone. I don't want to have to specify a timezone for every NSdate o

Compare two NSDate

I have a UIViewController with 2 buttons: today and yesterday. Every time the client clicked on today it needs to set the property _date for today and the same with yesterday. The method which I set the property value is the following: -(IBAction)dat

Get a string of localized dates from two NSDates

I'm running into an issue when it comes to taking two NSDates and displaying a localized string for the range. For example, say my dates are on July 7 and July 9. I would need the following localized strings: EN: July 7-9 FR: 7-9 Juliet ES: 7-9 Julio

Determine if two dates are in the same calendar day

My app presenting a list of messages, each has a creation date. I don't want to just show the date but to show different formats according to how much time passed from the creation date. for example, this is how I create the date string from the date

Find your next 20:00 hours from your chosen time

Given that I have a NSDate *timeRightNow which is the current time. How do I find the next 8:00 pm right from this time? Thus, if right now were 8:01 pm I would grab TOMORROW's 8:00pm If it were 7:59 pm, I would grab TODAY's 8:00 pm. So it's the next

NSString to NSDate issue IOS7

I'm using the following code to convert NSString to NSDate: NSDate *date = [NSDate convertStringToDate:strDate andFormatter:@"MM dd"]; + (NSDate *)convertStringToDate:(NSString *)dateString andFormatter:(NSString *)formatter { NSDateFormatter *d

NSDate in dd / MM / yyyy format

This question already has an answer here: Convert NSDate to mm/dd/yyyy 1 answer I want NSDate in dd/MM/yyyy format, without its time i.e. hh:mm:ss format. I can get string in this format but not nsdate. How to get nsdate like 27/12/2013? Thanks in ad

Adjust one-hour NSDate for daylight saving time

My app uses a feed from localendar.com to create a tableview of upcoming events. The issue though, is that the feeds from localendar do not account for DST, so they end up showing the pubDate of the feed as 1 hour later than the event actually starts

How to find missing days from a range of NSDates?

I have an NSMutableArray of ordered NSDates. I am looking for a method that returns all of the days (in NSDate form) that are missing from the original array between the earliest date in the array and now. I only care about the year, month, and day p

how to find the number of days

Possible Duplicate: iPhone - get number of days between two dates I am trying to compare 2 dates and find out the number of day in between them. something like below: now = [NSDate date]; // This is i am saving in NSUSerdefault on some condition,like

Convert the date in MM / dd / yyy format to xcode?

I have a UIDatePicker and I m getting the selected date from it in yyyy-MM-dd format.Now I want to convert it to MM/dd/yyyy format ..How can i do it ? NSDateFormatter *df=[[[NSDateFormatter alloc]init] autorelease]; df.dateFormat = @"yyyy-MM-dd"

Convert date to string without using NSDateFormatter

How to convert NSDate into NSString without use of NSDateFormatter? For Your reference my code as follows , i am using it for my reminder application. Thank You So Much. NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar]; // Get the curr

I can not get NSDate string

I have a [self.post post_time] NSDate with value of 2012-08-02T08:57:52.152713+00:00 NSDateFormatter *formatter = [[NSDateFormatter alloc] init] ; [formatter setDateFormat:@"yyyy-mm-dd"]; NSLog([formatter stringFromDate:[self.post post_time]]);

Convert NSDate to string with strftime

How would I convert an NSDate to a NSString, formatted with strftime specifiers?you could use strftime. NSDate *date = [NSDate date]; time_t time = [date timeIntervalSince1970]; struct tm timeStruct; localtime_r(&time, &timeStruct); char buffer[80

The simplest way to close two NSDates on iPhone?

What's the simplest way to loop from one date to another? What I want conceptually is something like this: for (NSDate *date = [[startDate copy] autorelease]; [date compare: endDate] < 0; date = [date dateByAddingDays: 1]) { // do stuff here } This d

What is the best way to store an NSDate in NSUserDefaults?

There's two ways of storing an NSDate in NSUserDefaults that I've come across. Option 1 - setObject:forKey: // Set NSDate *myDate = [NSDate date]; [[NSUserDefaults standardUserDefaults] setObject:myDate forKey:@"myDateKey"]; // Get NSDate *myDat