开发者

How do I render DateTime after it passes through Json

开发者 https://www.devze.com 2023-01-31 11:30 出处:网络
Our C# DateTime property comes through Json like this: /Date(1450674000000)/ How do we make that properl开发者_如何学JAVAy formatted as a date so we can display it in our HTML Tables?As Lazarus sug

Our C# DateTime property comes through Json like this:

/Date(1450674000000)/

How do we make that properl开发者_如何学JAVAy formatted as a date so we can display it in our HTML Tables?


As Lazarus suggested you could format it to a string representation of the date before serializing. You might need to add a new string property though. (i'm assuming you don't need the time component of the date object)

formatting could be done as shown below.

string dateStr = dateObject.ToString("dd-MMM-yyyy"); // format depends on your need or preference

Hope this helps.


I'd suggest formating it before you serialise it to Json.

0

精彩评论

暂无评论...
验证码 换一张
取 消