如何更改日期选择器中的日期格式 [英] How to change the format of date in date picker
问题描述
在我的iPhone应用程序中,我需要在 yyyy / MM / dd
格式显示日期,如beloow image
,但在iPhone日期选择器中,格式为 MM / dd / yyyy ,这对我的应用程序不统一
我尝试更改日期选择器的本地值(与不同的国家/地区),但是仍然使用默认格式。
如何更改日期格式根据我的要求在日期选择器上。
任何帮助都不胜感激。
在Apple的文档中,他们指定在 UIDatePickerModeDate
中。 DatePicker
显示月份,月份和年份。这些项目的确切顺序取决于 locale
设置。这种模式的一个例子是[November | 15 | 2007]。但在设备中显示为DD / MM / YYYY。有关详细信息,请参阅 UIDatePicker 。
所以如果你想自己做,你可以用你想要的值创建你自己的 UIPickerView
p>
In my iPhone app, I need to display date in yyyy/MM/dd
format as show in beloow image
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.
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.
这篇关于如何更改日期选择器中的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!