How do I pass a datetime value as a URI parameter in asp.net mvc?

前端 未结 10 1095
孤城傲影
孤城傲影 2020-12-04 18:58

I need to have an action parameter that has a datetime value? Is there a standard way to do this? I need to have something like:

mysite/Controller/Action/2         


        
10条回答
  •  清歌不尽
    2020-12-04 19:44

    I have the same problem. I use DateTime.Parse Method. and in the URL use this format to pass my DateTime parameter 2018-08-18T07:22:16

    for more information about using DateTime Parse method refer to this link : DateTime Parse Method

    string StringDateToDateTime(string date)
        {
            DateTime dateFormat = DateTime.Parse(date);
            return dateFormat ;
        }
    

    I hope this link helps you.

提交回复
热议问题