How to change the format of date in date picker

23,089

Solution 1

In Apple's documentation they specified that in UIDatePickerModeDate. The DatePicker displays months, days of the month, and years. The exact order of these items depends on the locale setting. An example of this mode is [ November | 15 | 2007 ]. But In device it display as DD/MM/YYYY. See UIDatePicker for more info.

So if you want to do it yourself you could create your own UIPickerView with the values you want.

Solution 2

The UIDatePicker is made to adapt to the user's settings. Changing its format using the locale: method was possible but is now deprecated in iOS 5.0.

You can view your format in the settings of your iPhone :

Settings > General > International > Region Format >

If you want a specific format, consider making your own picker but it is very discouraged for a date picker.

And also refer this Link

Share:
23,089
user1811427
Author by

user1811427

Updated on December 21, 2020

Comments

  • user1811427
    user1811427 over 3 years

    In my iPhone app, I need to display date in yyyy/MM/dd format as show in beloow image

    enter image description here

    but in iPhone Date picker it is in the format of MM/dd/yyyy which is not in uniform for my application

    I tried with changing the local values (with different country regions) of the Date picker but no use it still in the default format.

    How can I Change the date format on Date picker as per my requirement?

    Any help is appreciated.