How Do I Produce a Date format like “1st November” in c#

后端 未结 6 939
醉梦人生
醉梦人生 2020-12-06 05:31

How can i get below mentions date format in c#.

  • For 1-Nov-2010 it should be display as : 1st November

  • For 30-Nov-2010 it should be display a

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 06:02

    You can use Regular Expressions to extract the day and month. Then, store all the names of the months in an array and use the .startsWith to obtain the proper name of the month. You can use a simple case to see if you need the 'st', 'nd', 'rd' or 'th'.

提交回复
热议问题