How to format a date using NSDateFormatter

I added a date picker to view. But when I select any date from the collector, it shows this format:

Wednesday, December 14, 2011 1:50:52 PM India Standard Time 

I want to change this format to

 Wed, Dec 14 2011 1:50 PM 

How can I get this format using NSDateFormatter ?

+4
source share
1 answer

Try using the code below .it will help you

  NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"EEE, MMM dd yyyy hh:mm a"];//Wed, Dec 14 2011 1:50 PM NSString *str_date = [dateFormat stringFromDate:[NSDate date]]; NSLog(@"str_date = %@",str_date); 
+13
source

Source: https://habr.com/ru/post/1386261/


All Articles