Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a custom date format in iOS?

I want to display data int the next format: 14:23 Sep 10,2012.How can I do this?

like image 242
MainstreamDeveloper00 Avatar asked Dec 01 '22 21:12

MainstreamDeveloper00


1 Answers

Use NSDateFormatter

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"hh:mm MMM dd,yyyy"];
NSString *stringFromDate = [dateFormatter stringFromDate:[NSDate date]];
NSLog(@"today : %@", stringFromDate);
like image 154
Mani Avatar answered Dec 05 '22 10:12

Mani