Objective c date: NSString Date


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  1. NSDate* date = [NSDate date];
  2.  
  3. //Create the dateformatter object
  4.  
  5. NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
  6.  
  7. //Set the required date format
  8.  
  9. [formatter setDateFormat:@"yyyy-MM-dd"];
  10.  
  11. //Get the string date
  12.  
  13. NSString* str = [formatter stringFromDate:date];
  14.  
  15. //Display on the console
  16.  
  17. NSLog(str);
  18.  
  19. //Set in the lable
  20.  
  21. [dateLabel setText:str];

URL: http://www.roseindia.net/tutorial/iphone/examples/iphone-Objective-c-date.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.