I am using jQuery and the datetime values are not showing correctly.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Here is the model:
using System;
namespace GbngWebApi2.Models
{
public class BlogForMaint
{
public int BlogId { get; set; }
public int UserId { get; set; }
public int BlogCategoryId { get; set; }
public string BlogTitle { get; set; }
public bool ActiveSwitch { get; set; }
public int LikeCount { get; set; }
public int DisLikeCount { get; set; }
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime ModifiedDateTime { get; set; }
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime CreatedDateTime { get; set; }
}
}
Here is part of the view related to the dates:
"columns": [
{
"title": "Actions",
"data": "BlogId",
"searchable": false,
"sortable": false,
"render": function (data, type, full, meta) {
return '<a href="@Url.Action("Edit", "BlogMaint")?blogId=' + data + '" class="editBlog">Edit</a> | <a href="@Url.Action("Details", "BlogMaint")?blogId=' + data + '" class="detailsBlog">Details</a> | <a href="@Url.Action("Delete", "BlogMaint")?blogId=' + data + '" class="deleteBlog">Delete</a>';
}
},
{ "title": "User", "data": "UserId", "searchable": true },
{ "title": "Blog Title", "data": "BlogTitle", "searchable": true },
{ "title": "Published", "data": "ActiveSwitch", "searchable": true },
{ "title": "Like Count", "data": "LikeCount", "searchable": true },
{ "title": "DisLike Count", "data": "DisLikeCount" },
{ "title": "Modified", "data": "ModifiedDateTime" },
{ "title": "Created", "data": "CreatedDateTime" }
],
This is the data just before it is passed out of the web api to the web client (they look good):
This is how it looks as it gets back to the web client:
I see that the datetime has a T in it. "2020-05-01T13:05:43.103" Is that correct and the problem or is it something else?
entry:
{"Status":1,"BlogForMaintList":[{"BlogId":4,"UserId":1,"BlogCategoryId":1,"BlogTitle":"About","ActiveSwitch":true,"LikeCount":0,"DisLikeCount":0,"ModifiedDateTime":"2020-
05-01T13:05:43.103","CreatedDateTime":"2020-05-01T13:05:43.103"},
{"BlogId":5,"UserId":1,"BlogCategoryId":1,"BlogTitle":"Who I
am.","ActiveSwitch":true,"LikeCount":0,"DisLikeCount":0,"ModifiedDateTime":"2020-05-
01T13:05:43.11","CreatedDateTime":"2020-05-01T13:05:43.11"}]}
listValue = {[
{
"BlogId": 4,
"UserId": 1,
"BlogCategoryId": 1,
"BlogTitle": "About",
"ActiveSwitch": true,
"LikeCount": 0,
"DisLikeCount": 0,
"ModifiedDateTime": "2020-05-01T13:05:43.103",
"Cre...
listofentries :
[
{
"BlogId": 4,
"UserId": 1,
"BlogCategoryId": 1,
"BlogTitle": "About",
"ActiveSwitch": true,
"LikeCount": 0,
"DisLikeCount": 0,
"ModifiedDateTime": "2020-05-01T13:05:43.103",
"CreatedDateTime": "2020-05-01T13:05:43.103"
},
{
"BlogId": 5,
"UserId": 1,
"BlogCategoryId": 1,
"BlogTitle": "Who I am.",
"ActiveSwitch": true,
"LikeCount": 0,
"DisLikeCount": 0,
"ModifiedDateTime": "2020-05-01T13:05:43.11",
"CreatedDateTime": "2020-05-01T13:05:43.11"
}
]