Iphone Current Time Example
After going through this iphone SDK example, you will be able to show the current time on UILable. In this example we have used a UILable to show the output(current time) of the application and an UIButton(for button action).
Button actions are generally defined into ".h" file
method: "-(IBAction)currentdate:(id)sender;", and action methods are written in the ".m" file. Action method:
NSDate* date = [NSDate date];
//Create the dateformatter object
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
//Set the required date format
//Get the string date
NSString* str = [formatter stringFromDate:date];
//Display on the console
//Set in the lable
The application will look like this:
You can also download the complete code of "current time application in iphone"