Questions tagged [nsdatecomponents]

NSDateComponents is a class in Apple's Cocoa and CocoaTouch frameworks which represents either a date or a period of time as composed of several elements -- days, hours, and months, for example.

NSDateComponents encapsulates the components of a date in an extendable, object-oriented manner.

Resources:

567 questions
0
votes
2 answers

Finding how many times a day will appear from now until target date

I am making an iPhone count down app and need to know how many times a weekend (like Saturday and Sundays ) will happen until the date the user sets. An example is how could I find how many weekends will occur from now (Monday, August 6th) until…
Alex
  • 145
  • 1
  • 4
  • 15
0
votes
1 answer

iOS - TimeZone issue with difference between 2 NSDates

I've been using NSCalendar and NSDateComponents to return the difference (in days) between 2 dates. Here's the code I'm using to get that. NSCalendar *calendar = [NSCalendar currentCalendar]; calendar.timeZone = [NSTimeZone…
mhbdr
  • 753
  • 2
  • 10
  • 26
0
votes
2 answers

Time zone issue when retrieving an NSDate from Core Data

I am using this method to convert a month and year to a date which equals the last day in the month of the year given. + (NSDate*)endOfMonthDateForMonth:(int)month year:(int)year { NSCalendar *calendar = [[NSCalendar alloc]…
AlexR
  • 5,514
  • 9
  • 75
  • 130
0
votes
2 answers

NSDate coming null in iOS

I have to get a date from a string. So I am using the below code: NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; //Fri Mar 09 15:31:35 CST 2012 [formatter setDateFormat:@"EEE MMM d HH:mm:ss ZZZ yyyy"]; NSDate *date = [formatter…
dead_soldier
  • 429
  • 1
  • 5
  • 18
0
votes
2 answers

UIDatePicker, +/- 1 day difference when used as a string in UITextView

I have 2 date pickers, each one deference from the ether (280 day) the pickers change correctly, but mydatepicker.date when NSlog it or put it inUITextfield the date become date - 1 day or date + 1 day here is my code : the first picker: int…
Mutawe
  • 6,464
  • 3
  • 47
  • 90
0
votes
1 answer

NSCalendar Find Saturday and Sunday of Current Month

I am working on project where I want to integrate NSCalendar functionality in my app. Hence I googled and I found this solution. It give me all months in the year and also I can select particular date. that's fine. But I wanted to disable all…
iMash
  • 1,178
  • 1
  • 12
  • 33
0
votes
1 answer

Get latest occurence of a date by some interval with a specific original date in history?

For example: Original date: 23/03/2012 Interval: every 2 weeks Output: latest occurence -> 06/04/2012 How can I achieve this the best way in Objective-C (iOS)? Sidenote: My current not so working and really bad solution: + (NSDate *)…
Pieter
  • 1,751
  • 3
  • 30
  • 65
0
votes
1 answer

Find next Friday at 5pm from one time zone to another

I have an NSDate with a NZDT timezone and I need to find the next Friday at EST timezone. I have searched and have used NSDateComponents to generate dates but the timezone change is messing me up. If I add 3 days to the setWeekday and the present…
Eric
  • 157
  • 1
  • 11
-1
votes
2 answers

Obj-C Date - If earlier, make it tomorrow

I have an NSDate object, and I need to check if it has already passed. If so, turn that date into the date of tomorrow, but I can't lose information like TimeZone in the process. Could you plz help me?
-1
votes
3 answers

Adjusting Swift Date from one timezone to another is not producing expected result

I'm really struggling with dates and timezones. My understanding is Date is independent of timezone and is just a point in time. I'm writing a unit test and I want to create a Date object that would represent the time now if the user was in a…
Camsoft
  • 11,718
  • 19
  • 83
  • 120
-1
votes
1 answer

How can i print the dates of the first five month of a given year in the format below

I want to print the dates of the first 5 months in a given year with the formats below. 2019-05, 2019-04, 2019-03, 2019-02, 2019-01 Im using a for loop to achieve this var first5monthIn2019 : [String]{ var…
BigFire
  • 317
  • 1
  • 4
  • 17
-1
votes
1 answer

Swift: How should I subtract 5 minutes from Datecomponents?

I am working on an app that notifies the user 5 minutes before the departure time. I'm using firebase as my database. I've tried searching answers from the internet but the solutions are not working. So here's the code in getting the departure hour…
Pengu
  • 19
  • 4
-1
votes
1 answer

NSDateComponents wrongly adds one extra hour

I'm trying to create a method in Objective-C which would get the total number of minutes from a time value, written in "HHmm" format. E.g. for "0210" the return value should be 130. + (int)totalMinutesFromHHmm:(NSString *)HHmm { NSDateFormatter…
Bedford
  • 1,136
  • 2
  • 12
  • 36
-1
votes
2 answers

How to print name of the day of the week?

Im trying to print out the name of the day of the week i.e Monday, Tuesday, Wednesday. I currently have this bit of code that does just that. I was wondering if there is a way to get rid of my switch statement and make this better. Thanks! func…
user7097242
  • 1,034
  • 3
  • 16
  • 31
-1
votes
1 answer

How to filter array of dates with textfields in iOS swift?

I have two textfields one is containing "From Date" and another one is containing "To date" based on that how to filter array of dates.
kishore
  • 3
  • 6