【问题标题】:Datetime issues while sending and receiving through json通过json发送和接收时的日期时间问题
【发布时间】:2019-06-04 23:20:33
【问题描述】:

我在从角度选择日期时间选择器时得到这个日期和时间 “2019 年 1 月 10 日星期四 00:00:00 GMT+0400(海湾标准时间)” 我系统中的实际日期时间是 2019 年 1 月 10 日 9.51

当我在 asp.net api 中接收数据时,我得到一个这样的日期。 {09/01/2019 晚上 8:00:00}

角度。

    export interface sample{
        vr_date: Date
    }

`this.adapter.setLocale('en-GB');` // i use this to get date format in dd/mm/yyyy format

asp api

public class sample
{

        public Nullable<System.DateTime> vr_date{ get; set; }
}

【问题讨论】:

    标签: javascript asp.net angularjs json


    【解决方案1】:

    在转换为 JSON 之前将日期转换为字符串。

    使用-

    var date=dateObject.toLocaleDateString();
    

    然后通过 JSON 发送日期。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多