Is there a standard date/time format that can be passed on a URL?

前端 未结 8 1727
臣服心动
臣服心动 2021-01-01 13:51

Looking at the DateTimeFormatInfo documentation, it appears that all the standard formats have colons in them, which makes passing them on a url unpleasant/impossible.

8条回答
  •  醉梦人生
    2021-01-01 14:31

    If you need the date and time, I would use DateTime.Ticks.

    If you only need the date, use HttpServerUtility.UrlEncode(date.ToShortDateString()).

    Update: Rick Strahl has discussed this issue before and has offered a solution on his blog.

提交回复
热议问题