format date in linq query result

后端 未结 4 1014
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-18 02:42

The following linq to entities query gives the result below:

public class UserCountResult
{
    public DateTime? date { get; set; } // **should this be strin         


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-18 03:28

    Something like this should work:

    date = new Date(parseInt(g.Key.substr(6)));
    

    The substr will pull off the "/Date(" string, parseInt will pull just the integer and Date will give you a new date object.

    EDIT:

    Just found this SO question that supports this answer.

    How do I format a Microsoft JSON date?

提交回复
热议问题