How to change format of date/time?

后端 未结 2 1084
自闭症患者
自闭症患者 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:06

    I think your formatting string is the problem. You should only use the characters you find in the table in UTS#35 Date Format Patterns. I tried your code and while the time hh:mm displays correctly, formatting stops at tt - not in the table!

    If you really want characters in the format string that are not in the table you can escape them, like hh 'o''clock' a, zzzz - produces format like "12 o'clock PM, Pacific Daylight Time".

提交回复
热议问题