Remove year from NSDateFormatterFullStyle string
I have searched for this question and didn’t find a conclusive and elegant solution. Is there anyway to change the NSDateFormatterFullStyleyear to suppress year information. I’m using the code:
NSString *dateDescription; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; [dateFormatter setTimeZone:gmt]; [dateFormatter setDateStyle:NSDateFormatterFullStyle]; dateDescription = [dateFormatter stringFromDate:date]; NSLog(@"%@", dateDescription);
The result: Wednesday, March 13, 2013
- How to open Settings programmatically like in Facebook app?
- iPhone/iOS: How can I get a list of localized strings in all the languages my app is localized in?
- Connect with iOS and Android clients to SockJS Backend
- check if control center is used
- How can I detect screen lock/unlock events on the iPhone?
- How to identify different connected watches in iOS
Solutions Collect From Internet About “Remove year from NSDateFormatterFullStyle string”
The following is the closest you will get without lots of tricky string processing. The call to
dateFormatFromTemplate:options:locale: will update the supplied template to best match the specified locale.
This assumes that the normal “Full” style gives you the weekday name, month name, and day of the month.
NSString *fullMinusYear = [NSDateFormatter dateFormatFromTemplate:@"EEEE, MMMM dd" options:0 locale:[NSLocale currentLocale]]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:fullMinusYear]; NSString *dateDescription = [dateFormatter stringFromDate:date];
- Programmatically Checking if a Passcode Lock is Set
- Most memory efficient way to save a photo to disk on iPhone?
- Verifying In App Purchase Receipt from Client
- How can I get ViewController from TabBarController on AppDelegate?
- How to ensure destruction of singleton in IOS 5 with ARC?
- Xcode 8 beta 4: “Could not attach to pid : 1110” when running on physical device
- Objective-C Library for RSS feed parsing?
- How can I optimize the rendering of a large model in OpenGL ES 1.1?
- iPhone 4 Simulator for Xcode 6
- NSDate return “1604” for year value?
- iOS 7 and Helvetica Neue UltraLight: use as default for older iOS versions
- how to throw errors in a closure in swift?
- How to manage cookies with UIWebView in Swift
- Converting NSDecimalNumber to NSString
- UISearchController won't dismiss searchbar and overlap for iOS 8 Swift