jquery - 如何从jquery中的以下json字符串中提取确切日期
问题描述
public class Plans
{
public long PlanID { get; set; }
public long? CompanyID { get; set; }
public string PlanType { get; set; }
public string PlanName { get; set; }
public bool? IsActive { get; set; }
public int? CreatedBy { get; set; }
public DateTime? CreatedDate { get; set; }
public int? CheckedBy { get; set; }
}
var date = [{
0:
BusinessType: "null"
CheckedBy: null
CheckedDate: null
CompanyID: null
CompanyName: "Swastik"
CreatedBy: null
CreatedDate: "/Date(1587383258707)/"
}];
从视图中添加了控制器方法和 ajax 调用以获得更好的帮助。无法找到执行此操作的方法。我无法找出如何从上面在 jquery 中检索到的 json 字符串中提取日期。请协助我。在我正在使用的上面添加了我的模型类。我只是通过调用一个过程并使用 ajax 调用从控制器呈现数据以查看并在控件中填充 ajax 调用成功数据来获取数据。
解决方案
另一种方法,我所做的是在我的模型中创建另一个属性/函数。
你在asp中的模型
public class YourModel{
public DateTime CreatedDate {get;set;}
// if you want through model
public string FormattedCreatedDate {get { return CreatedDate.ToString("dd-MM-yyyy");}}
// or through functions
public string GetFormattedCreatedDate(){
return CreatedDate.ToString("dd-MM-yyyy");
}
}
推荐阅读
- elasticsearch - 如何在使用 docker-compose 运行服务时查看应用程序特定的日志
- json - 屏蔽 json 值内的特定数据
- html - 如何对齐几何形状
- javascript - Tiptap (Prosemirror) 提及标签的协作模式错误
- mysql - MYSQL如何从两个表mysql中获取唯一值
- reactjs - 带有 SWR 的 getStaticProps “错误序列化从 `getStaticProps` 返回的 `.initialData.config.transformRequest[0]`”
- css - 不同宽度的模态对话框不适用于 :host 和 :ng-deep
- laravel - 当条件限制为 2 时执行代码 3 次
- r - ggplot 折线图显示所有单个值而不是平均值
- c# - microsoft.extensions.configuration .Net 框架 4.7 迁移