Convert NSDate to NSString with NSDateFormatter with TimeZone without GMT Time Modifier
I’m initializing my NSDateFormatter thusly: NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@”en_US_POSIX”] autorelease]]; [dateFormatter setDateFormat:@”EEE, d MMM yyyy HH:mm:ss z”]; [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; NSDate *date = [NSDate date]; NSString *dateString = [dateFormatter stringFromDate:date]; dateString is now: Thu, 29 Jul 2010 14:58:42 GMT+00:00 I want to get rid of the “+00:00” I’m […]
Determine if current local time is between two times (ignoring the date portion)
Considering that there is no NSTime in Cocoa-Touch (Objective-C on iPhone), and given two times as NSStrings and a timezone as an NSString, how can you calculate whether or not the current LOCAL time is between these two times. Keep in mind that the date in the time strings do NOT matter, and are filled […]
Can we change the device time using an application?
Want to know whether its possible to change the time of the iPhone through an application.. Is that level of dev access granted in iOS4? My gut feeling is no, but I’m looking for a definitive Yes/No answer if possible. Note: NSTimeZone class states ‘Cocoa does not provide any API to change the time zone […]
Why isn't my time zone being saved into my NSDate?
I must initialize an NSDate object from NSString in objective-c. I do it like this: NSString *dateString = [[webSentence child:@”DateTime”].text stringByReplacingOccurrencesOfString:@”T” withString:@” “]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@”yyyy-mm-dd HH:mm:ss”]; [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@”Europe/Budapest”]]; NSDate *date = [[NSDate alloc] init]; date = [dateFormatter dateFromString:dateString]; E.g: when I try it with string value @”2011-01-02 17:49:54″ […]
NSDateFormatter and Time Zone issue?
I have a string with time in GMT and i want to make it according to the system time zone but its not working properly – NSLog(@”Time Str = %@”,Time); NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@”dd-MM-yyyy hh:mm a”]; [NSTimeZone resetSystemTimeZone]; NSLog(@”system time zone = %@”,[NSTimeZone systemTimeZone]); [dateFormat setTimeZone:[NSTimeZone systemTimeZone]]; NSDate *date = [dateFormat […]
How to find out the current time in different timezone in xcode for an iphone application? Suppose i’m in India and i want to know the current time in USA how do i get the time then. Thanks in advance Joy
Is there a way to get Xcode's debugger to show dates in local timezone (i.e., not UTC)?
I’m trying to debug code that makes pretty heavy use of dates which has me comparing tons of different NSDate values in the debugger. The debugger is displaying those dates in UTC format–for example: date1 = (NSDate *) 0x01b11460 @”2012-02-15 18:55:00 +0000″ It would be a lot easier for me if it would show them […]
Where is the iPhone's Date & Time getting its time zone list
I can get a list of time zones with [NSTimeZone knownTimeZoneNames], but that only gives the time zone IDs which include one or two cities in each time zone. The Date & Time settings has a great list of cities and I have seen a few other apps that have the same if not similar […]