Home > Tutorials Home > Ios > DateTimePicker Control in iOS

DateTimePicker Control in iOS

Published on October 17, 2019 8:11:18 PM


We are an online tutoring company that has laid its foundation in utilizing Multiple Intelligence methodology to understand specific needs and learning styles of a student.UIDatePicker object sends an action message when a user finishes rotating one of the wheels to change the date or time; the associated control event is UIControlEventValueChanged.So that we patch a particular student to a tutor having a compatible teaching style. We have devised a smart online tutoring system to give you measurable results.Schools, cramped with students, fail to give your child the edge, the motivation and the right teacher guidance to help him find the true potential. We at make sure that your child gets the perfect learning environment to outperform.

Step 1 : Open the XCode and create a new Single View Based Application template. Give the application name "Multiple Button in AlertView Example". Copy this Code to the ViewController.h and hook up the properties with appropriate control.

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@property (weak, nonatomic) IBOutlet UIDatePicker *DatePickerControl;
@property (weak, nonatomic) IBOutlet UILabel *lblMessage;
@property (weak, nonatomic) IBOutlet UIButton *TimeMode;

- (IBAction)DateMode:(id)sender;
- (IBAction)timeMode:(id)sender;
- (IBAction)UpdateDate:(id)sender;


Step 2 : Copy the Following Code into your ViewController.m File.

#import "ViewController.h"

@implementation ViewController

@synthesize TimeMode;
@synthesize DatePickerControl;
@synthesize lblMessage;

- (IBAction)DateMode:(id)sender
    DatePickerControl.datePickerMode = UIDatePickerModeDate;

- (IBAction)timeMode:(id)sender
    DatePickerControl.datePickerMode = UIDatePickerModeTime;

- (IBAction)UpdateDate:(id)sender
    NSDate *myDate =;
    NSDateFormatter *formater = [[NSDateFormatter alloc]init];
    formater.dateFormat = @"dd-MMMM-yyyy hh:mm:ss";
    NSString *current = [formater stringFromDate:myDate];
    [lblMessage setText:current];


DateTimePicker Control in iOS - Video Tutorial