Posted By

espinallab on 02/02/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

bobbym245


Objective c date: NSString Date


 / Published in: Objective C
 

URL: http://www.roseindia.net/tutorial/iphone/examples/iphone-Objective-c-date.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];

Report this snippet  

You need to login to post a comment.