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

后端 未结 6 938
醉梦人生
醉梦人生 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:16

    I'm pretty sure there's no datatime routine to show the date as 1st or 30th.

    I recently wrote some code like that from scratch. I think you'll need to do the same.

    I don't have my code handy but I just created a string array with the letters for each number ("th", "st", "nd", "rd", "th", etc.). Then mod against 10 and use the remainder as an index into the array. You can just append that string to your number.

提交回复
热议问题