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

前端 未结 8 1728
臣服心动
臣服心动 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:46

    For what it's worth, ASP.NET MVC won't automatically convert ticks to a datetime either, which surprised me.

    There's a constructor for DateTime that takes the number of ticks:

     DateTime d = new DateTime(634028202671420663);
    

    There's also an override that lets you map that to either local or UTC time. It's all in the docs: http://msdn.microsoft.com/en-us/library/system.datetime.datetime.aspx

    Edit: realised from the wording of the post that perhaps you're talking about ASP converting the ticks automatically to a DateTime, rather than having to read the numeric parameter. Perhaps! :-)

提交回复
热议问题