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
-2
votes
1 answer

How to get first date of MONTH, and first date of YEAR for a incoming date. in iPhone Objective c

Possible Duplicate: How to get all the days/dates in current week, this month, this year using the current date (today) in iPhone I need to get the first day of Month, first day of Year for a date (Most of times input date is current date…
user1811427
  • 359
  • 2
  • 6
  • 17
-2
votes
1 answer

Take date information from ipad

We need to take the actual date from the IPad and save it in a variable. We have searched NSDateComponents and NSDate, but we havent found anything. For example if today is 25 of october, we would like to have a int with the value of 25 and another…
iopy
  • 5
  • 1
  • 4
-3
votes
1 answer

How to get Current Date, Time, Year from NSDate?

Here is the situation I have a method as + (NSDateComponents *)getTodayComponents { NSDate *today = [[NSDate alloc] init]; NSCalendar *calendar = [NSCalendar currentCalendar]; return [calendar components:NSCalendarUnitYear |…
daydreamer
  • 87,243
  • 191
  • 450
  • 722
-3
votes
1 answer

From date cannot be nil in Objective-c

I'm trying to get the seconds between two dates, for this I'm using the NSDateComponents: NSString *start = components2[0];// 2014-10-14 20:52:43 NSString *end = components[0];// 2014-10-14 20:54:40 NSLog(@"Start -> %@, End ->…
user3781174
  • 245
  • 5
  • 16
-3
votes
1 answer

How to get NSDateComponents between two NSDateComponents?

I've two NSDateComponents, I want all NSDateComponents in between those two, I've tried the following, NSDateComponents *first = ...; NSDateComponents *second = ...; BOOL boolDone = NO; while (!boolDone) { [array addObject:first]; …
Hemang
  • 26,840
  • 19
  • 119
  • 186
-3
votes
3 answers

Converting can NSString to NSDate format in objective C

How can i convert the following string "October 24,Monday 12:30 AM EST" to NSDateFormat. i tried this code NSDateFormatter *dateformat=[[NSDateFormatter alloc]init]; [dateformat setDateFormat:@"MM/DD/YYYY hh:mm a"]; NSDate *datefor=[dateformat…
-3
votes
6 answers

How to format time with NSDateFormatter like this HH:mm:ss

I have the duration of a song in seconds. After following calculations, I have the time in hour, minutes and seconds. int hour = time / 3600; int minute = (time / 60) % 60; int second = time % 60; I need to show them with this format HH:mm:ss How…
aakpro
  • 1,538
  • 2
  • 19
  • 53
-4
votes
2 answers

Format hour and minute integers as the String "9:30 am"

How can I express hour and minute integer values as a String formatted like "9:30 am"? Currently, I have: let hour: Int = 9 let minute: Int = 30 var dateComponents = DateComponents() dateComponents.hour = hour dateComponents.minute = minute let…
Eric33187
  • 1,006
  • 7
  • 13
-5
votes
1 answer

Does dateComponents use 24 hour time? (scheduling local notifications)

This code would create a notification trigger that repeats every day at 10am, right? var dateComponents = DateComponents() dateComponents.hour = 10 dateComponents.minute = 0 let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents,…
RanLearns
  • 4,086
  • 5
  • 44
  • 81
-5
votes
1 answer

How can I get my current date ios Swift?

Specifically I would like to print my current date formatted like this - 2016-12-08 03:37:22 +0000. I've tried NSDateComponents. Swift 2.1 is telling me NSSecondCalendarUnit is deprecated and it doesn't recognize NSCalendarUnitSecond. What is…
Charles Jr
  • 8,333
  • 15
  • 53
  • 74
-8
votes
1 answer

How to get timestamp from a String like "2017-08-30T06:40:00.000+00:00" in Swift 3?

consider the string like "2017-08-30T06:40:00.000+00:00" 1 - How to convert this string into timestamp 2 - How to group this value into time slots (for eg, if the value is time = 2:30 PM, it will be grouped into the slot of 2pm to 3pm)
u7568924
  • 83
  • 1
  • 9
-8
votes
2 answers

How to convert NSDateComponents to DateComponents in Swift

I want to conver NSDateComponents to DateComponents. How can I do it in Swift without force casting.
Encore PTL
  • 8,084
  • 10
  • 43
  • 78
1 2 3
37
38