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
3 answers

Wrong date comes back from NSDateComponents

Why is this giving me the wrong date ? NSCalendar *myCalendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar]; NSDateComponents* components = [myCalendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit…
Steaphann
  • 2,797
  • 6
  • 50
  • 109
0
votes
1 answer

Trying to get Weekday using NSDateComponents but weekday always the same

I'm trying to obtain the day of the week using the code below with a variable NSString. Whatever value I use the weekday always comes back as 2. What am I doing wrong? NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; [dateFormatter…
user616076
  • 3,907
  • 8
  • 38
  • 64
0
votes
1 answer

NSCalendarUnit – modifying unitFlags

In my app I want to let user set display style of a date. I've considered to just modify unitFlags to achieve that. I mean this NSUInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekCalendarUnit | NSDayCalendarUnit; But here's the…
Randex
  • 770
  • 7
  • 30
0
votes
2 answers

NSDate convert NSDateComponents issue

The results of destinationDate and components differ. how do i solve this problem? NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; NSTimeZone* destinationTimeZone = [NSTimeZone systemTimeZone]; NSDate* sourceDate …
realmasse
  • 523
  • 1
  • 6
  • 18
0
votes
2 answers

ios set UIDatePicker time ahead

I grab the current time NSDate * now = [[NSDate alloc] init]; NSCalendar *cal = [NSCalendar currentCalendar]; NSDateComponents * comps = [cal components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:now]; And I can set the…
Jesse Meyer
  • 315
  • 1
  • 3
  • 12
0
votes
1 answer

How do I disable time Period on UIDatePicker?

I am working on an app that involves gathering components of 2 UIDatePickers, one for time and one for the date. I would love to if possible remove the Period column (AM/PM) from the time picker. If this is not possible, I still have not been able…
willbattel
  • 1,040
  • 1
  • 10
  • 37
0
votes
0 answers

Show local notification on particular days

Today's date is 2013-04-17 10:39:00 +0000. Now i am selecting weekdays from table to set schedule(alarm) of that day. I want to show local notification alert on selected days forever. But i am getting problems. Here is my…
shivam
  • 1,148
  • 1
  • 12
  • 28
0
votes
4 answers

Issues in NSdate (Time Zone) date Time displays 5hrs 30 mins past time

Actually in my simulater TIME displays past 5 hrs 30 mins My current time in india is 2013-04-02 09:10:__ AM But the output is 2013-04-02 03:54:51 +0000 2013- April - 2nd : 9:10 AM I need to get some results between two dates 1.First Date of month…
iOS dev
  • 2,254
  • 6
  • 33
  • 56
0
votes
2 answers

NSDateComponents from NSDate yielding unexpected results

I have an NS date stored that is logged as 2013-03-15 00:00:01 +0000 I presume that the +0000 is UTC time. However, when I try NSCalendar* theCalendar = [NSCalendar currentCalendar]; unsigned theUnitFlags = NSDayCalendarUnit | NSHourCalendarUnit…
SAHM
  • 4,078
  • 7
  • 41
  • 77
0
votes
1 answer

calculating number of days, nsdate, ios

The way I am calculating the difference between of 2 dates is NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *nowAndEnd = [calendar components:NSMonthCalendarUnit| …
tranvutuan
  • 6,089
  • 8
  • 47
  • 83
0
votes
3 answers

how to trigger a download on specific date

In my iPhone application I want to trigger a download every monday of a week, every 10th working day of a month, every 3rd day of a month etc. I did some R & D and found that NSDate, NSDateComponents & NSCalendar classes needs to be used for this…
Srivathsa
  • 606
  • 10
  • 34
0
votes
3 answers

NSDateFormatter returns nil for specific date only in certain time zones

Given this code: NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"yyyyMMdd"]; NSArray *datesArray = @[@"20130326", @"20130327", @"20130328", @"20130329", @"20130330", @"20130331",…
user2393462435
  • 2,652
  • 5
  • 37
  • 45
0
votes
1 answer

Is the iOS Do Not Disturb Bug Causing this Bug?

I am trying to find out if the recent Do Not Disturb bug (Ars Technica link) is affecting my code. I am trying to get the date and timestamp for midnight the previous Monday. Since I am writing this on a Monday, I would expect to get today's date…
Mike D
  • 4,938
  • 6
  • 43
  • 99
0
votes
3 answers

Getting all NSDates from now unwanted behavior

I want to get all NSDate from to to 30 days later. However it doesn't work correctly. Here is the code i am using: for (int i = 0; i < days; i++) { NSDate *today = [self getToday]; NSCalendar *gregorian = [[NSCalendar alloc]…
Streetboy
  • 4,351
  • 12
  • 56
  • 101
0
votes
2 answers

Objective C: Incorrect Output while using NSDates

I am trying to get the start and end dates of the current month. There are a few similar questions here, but I am getting unexpected results while using them. Here's what I did: NSDate *monthStart,*monthEnd; NSCalendar *cal = [[NSCalendar alloc]…
Ruben Roy
  • 587
  • 3
  • 15
  • 28