Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the format of date in date picker

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.

like image 329
user1811427 Avatar asked Dec 19 '12 12:12

user1811427


2 Answers

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.

like image 109
Roland Keesom Avatar answered Sep 18 '22 01:09

Roland Keesom


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

like image 22
thavasidurai Avatar answered Sep 18 '22 01:09

thavasidurai