nsdate

How to print the NSDate as Julian calendar formatted date in iphone?

瘦欲@ 提交于 2019-12-13 04:29:58
问题 I want to display Julian Calendar formatted dates. How can I do this using NSLog? I only got the Georgian calendar values. 回答1: You can use this formula to convert Gregorian calendar date to Julian date. 来源: https://stackoverflow.com/questions/12000399/how-to-print-the-nsdate-as-julian-calendar-formatted-date-in-iphone

Swift check NSDate is not nil

前提是你 提交于 2019-12-13 03:43:34
问题 I'm getting a value from userDefaults which might be nil or might be an NSDate, so I want to check since I need to act on that date. How would I correctly do the check? let timeAtQuit: NSDate = (userDefaults.objectForKey("timeAtQuit") as NSDate) if(timeAtQuit){ Type 'NSDate' does not conform to protocol 'BooleanType' if(timeAtQuit != nil){ // 'NSDate' is not convertible to 'UInt8' another attempt: var timeAtQuit:NSDate? = (userDefaults.objectForKey("timeAtQuit") as NSDate) if(timeAtQuit !=

Objective C - create NSDate from two Strings

旧时模样 提交于 2019-12-13 03:22:43
问题 Short version: Is there a way to combine two NSDates (which can be formed from two different strings) into a single NSDate object? Detail: In my app, there are two textfields where the user enters the day and the time, respectively (these are entered using a customised Date Picker). When I want to save the information in the database, the property of the object expects a single date, comprised of both the day and the time. Here is how I set the strings: if ([mode isEqualToString:@"date"]) {

Forming a predicate to filter between dates

杀马特。学长 韩版系。学妹 提交于 2019-12-13 03:16:45
问题 Say I have two dates: minDate:2012-08-29 12:22:17 +0000 maxDate:2011-12-01 18:14:38 +0000 I have a Core Data object called MBDate which has an NSDate property. I want to get all MBDate's with days including and in between the days above. So it should disregard the hours, seconds, and minutes, and just get all days in between and including 8/29 - 12/01. Something like: predicate = [NSPredicate predicateWithFormat:@"date < %@ AND date > %@", maxDate, minDate]; But I'm not sure how I would tell

How can i get date of a coming day - Objective C [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 03:03:53
问题 This question already has answers here : Get the date of next saturday in Objective-C? (3 answers) Closed 6 years ago . If I say upcoming monday then how can I get date of upcoming monday ? Like, today is Thu, 04-04-2013 than how can I get what date will be on coming wednesday ? Hope I am able to clarify you. Similar question was asked here but I'm not able to understand this: Get the date of next saturday in Objective-C? 回答1: NSCalendar *gregorian = [[NSCalendar alloc

Need to convert NSString to Nsdate

最后都变了- 提交于 2019-12-13 02:59:52
问题 I need to convert "2013-05-05T00:00:00Z" this string to NSDate and again NSDate to Nsstring. I have tried with different-differnt format style but didn't get any success. I have already checked. NSDate from NSString Convert NSDate to Sql Server Datetime format Thanks. // for getting string for Advance search -(NSDate*) doGetDateFromStringGSearch :(NSString*) dateStr { NSDateFormatter * outputFormatter4 = [[[NSDateFormatter alloc ] init ] autorelease ]; NSLocale *locale = [[NSLocale alloc]

NSDate ivar become <not an Objective-C object>?

谁说胖子不能爱 提交于 2019-12-13 02:51:53
问题 - (id)initWithCoder:(NSCoder *)aDecoder { dueDate = [NSDate date]; } - (void)viewDidLoad { [super viewDidLoad]; NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease]; [formatter setDateStyle:NSDateFormatterShortStyle]; [formatter setTimeStyle:NSDateFormatterShortStyle]; self.lbDueDate.text = [formatter stringFromDate:dueDate]; } In init method I declared dueDate = [NSDate date]. But when I debug, at this line self.lbDueDate.text = [formatter stringFromDate:dueDate]; And

Swift countDown timer Logic

≯℡__Kan透↙ 提交于 2019-12-13 01:44:05
问题 I'm creating a countdown timer by the day, hour and second. I'm currently storing them in a String array while also converting them into an Int ( using map() ) so that I can countdown/decrement when I make the values into a label. The current output when printing to the logs is: ["[68168]", "[68188]", "[68243]", "[68281]"] I'm having trouble forming the logic of a countDown function so that when seconds hits "0", 1 minute goes down, and after 59 minutes 1 hour is decremented, etc., until it

Sort NSDates inside NSDictionary inside NSArray?

梦想的初衷 提交于 2019-12-13 01:14:33
问题 Currently in my app I have a NSArray that I load from NSUserDefaults. Each object in the NSArray is a NSDictionary that has about 5 different keys. I am re-order the NSDictionarys themselves based upon the NSDates inside of them. I do not want to sort the NSDates alone. I have tried to do this with this code: NSComparator sortByDate = ^(id dict1, id dict2) { NSDate* n1 = [dict1 objectForKey:@"Date"]; NSDate* n2 = [dict2 objectForKey:@"Date"]; return (NSComparisonResult)[n1 compare:n2]; };

how to get start and end time from datepicker in swift?

二次信任 提交于 2019-12-12 23:46:52
问题 i want to get start and end time from date which i select from datepicker. here is my code func handleDatePicker(sender: UIDatePicker) { let dateFormatter = NSDateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss" let startOfDay = NSCalendar.currentCalendar().startOfDayForDate(sender.date) let components = NSDateComponents() components.hour = 23 components.minute = 59 components.second = 59 let endOfDay = NSCalendar.currentCalendar().dateByAddingComponents(components, toDate: