nsdateformatter

Calculate time elapsed between pressing the same button twice

本秂侑毒 提交于 2019-12-13 07:17:29
问题 I've tried all the time calculating examples I found on this site but somehow I'm getting 0 as value every time. I'm new to IOS and the NSDate is giving me a run for it's money :) I want to record time A when I press button "startStop", and then record time B when I press it again. Pressing it a second time (deselecting) has to calculate the time elapsed between these 2 dates. So far I have this: -(IBAction)buttonClick { NSDate *startStopDate = [NSDate alloc]; NSDateFormatter *formatter= [

NSTimeInterval seems to be wrong for last day of the given month- iOS

↘锁芯ラ 提交于 2019-12-13 05:41:18
问题 In my local database, I have a list of NSTimeInterval values saved. I have to find out and fetch all records available in a given Month. The only problem is in fetching records for last day of the given month seems to be unavailable. Lets say given month is December so I have to fetch all the records from 1st Dec to 31st Dec (Till 11:59PM) I am using following implementation: [self.dateFormatter setDateFormat:@"dd-MM-yyyy"]; NSDate *startDate = [self.dateFormatter dateFromString:@"1-12-2012"]

NSDateFormatter fails parsing three letter abbreviation of German month March/June/Jul

守給你的承諾、 提交于 2019-12-13 05:38:57
问题 I have a number of German dates in the format of "10.Feb.2016", i.e. 2 digits for the day, 3 letters for the month, 4 digits for the year. I tried to use the date format dd.MMM.yyyy , but that fails for 3 German months: 10.Mär.2016 10.Jun.2016 10.Jul.2016 That's because that's according to the docs, MMM actually stands for "date abbreviation", which does to guarantee or imply exactly three letters. How can I parse a date with exactly three letters for the month that will work in any language?

NSString to NSDate using NSDateFormatter returns null

混江龙づ霸主 提交于 2019-12-13 05:30:33
问题 dateFromString returns me null when I am trying to convert NSString to NSDate here is my code: NSString *dateString = @"Wed 16 Oct 2013"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setLocale:[NSLocale systemLocale]]; [dateFormatter setTimeZone:[NSTimeZone systemTimeZone]]; [dateFormatter setDateFormat:@"EEE dd MMM yyyy"]; [dateFormatter setFormatterBehavior:NSDateFormatterBehaviorDefault]; NSDate *myDate = [dateFormatter dateFromString: dateString]; Please

Convert a float into a time format mm:ss

跟風遠走 提交于 2019-12-13 05:09:38
问题 I'm searching a way with Objective-C to convert a float (audioPlayer.currentTime, which for example = 3.4592) into a time string with minutes and seconds (03:46) I tried this: static NSDateFormatter *date_formatter = nil; if (date_formatter == nil) { date_formatter = [[NSDateFormatter alloc] init]; [date_formatter setDateFormat:@"mm:ss"]; } NSDate *diff = [[NSDate alloc] initWithTimeIntervalSinceNow:audioPlayer.currentTime]; NSLog(@"%@", [date_formatter stringFromDate:diff]); ... but that's

Fetch from Core Data sorted by formatted date

雨燕双飞 提交于 2019-12-13 04:55:48
问题 I am having trouble fetching results from Core Data that are sorted by date. I have a DB table that contains football matches. Each match has a homeTeam, awayTeam and kickoffTime. The kickoffTime is an NSDate that stores the date and time the match will start. I want to display the results of a query in a TableView divided into sections by the kickoff date. With the date as the section heading. This is a little more complex than it might first appear. Due to differing time zones a match

NSDataFormatter dateFromString results in incorrect output

江枫思渺然 提交于 2019-12-13 04:54:56
问题 Here is my code : [dateFormat setDateFormat:@"EEE MM d HH:mm:ss yyyy"]; logDate = [dateFormat dateFromString:[line substringToIndex:24]]; line consist of string : "Mon Feb 18 09:25:53 2013: FAILED : Configuration-Update : " I get the date alone "Mon Feb 18 09:25:53 2013" and formatted it with @"EEE MM d HH:mm:ss yyyy" format. I get an incorrect output : "2013-02-18 03:55:53 -0000" Time alone is printed incorrectly. I followed Date Format Patterns for specifying patters but still I am phasing

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]

DateFormatter “HH” not giving time in 24 hour format in swift [duplicate]

。_饼干妹妹 提交于 2019-12-13 02:57:23
问题 This question already has an answer here : swift NSDateFormatter not working (1 answer) Closed last year . I am trying to fetch the currentTime in a 24 hour format with UTC timezone. When I have debugged my app in different devices, I came across a strange problem. The code works perfectly fine in my device, however it gives time in 12 hour format in my cousin's iPhone having iOS 11.2. So I have tried running app in another device which is iPhone X with same os. I am not sure what went wrong