How to change format of date/time?

后端 未结 2 1080
自闭症患者
自闭症患者 2021-01-25 08:32

I have this date and time format:

2010-05-19 07:53:30

and would like to change it to:

Wednesday @ 7:53PM 5/19/2010
2条回答
  •  再見小時候
    2021-01-25 09:01

    It would be nice if time and date could come out as separate properties so I can arrange them however I like. Any ideas on how I can change the formatting?

    You have things backwards. If this is a date/time to be displayed to the user, you need to present it how the user wants it, not how you want it. For instance, most people outside the USA will be confused by MM-dd-yyyy particularly if the day is less than 13. Consider using -setDateStyle: and -setTimeStyle:. That way, the display string will come out as the user expects.

提交回复
热议问题