How do I format a Microsoft JSON date?

后端 未结 30 3184
伪装坚强ぢ
伪装坚强ぢ 2020-11-21 04:48

I\'m taking my first crack at Ajax with jQuery. I\'m getting my data onto my page, but I\'m having some trouble with the JSON data that is returned for Date data types. Basi

30条回答
  •  爱一瞬间的悲伤
    2020-11-21 04:49

    You also can use the JavaScript library moment.js, which comes in handy when you plan do deal with different localized formats and perform other operations with dates values:

    function getMismatch(id) {
        $.getJSON("Main.aspx?Callback=GetMismatch",
        { MismatchId: id },
    
        function (result) {
            $("#AuthMerchId").text(result.AuthorizationMerchantId);
            $("#SttlMerchId").text(result.SettlementMerchantId);
            $("#CreateDate").text(moment(result.AppendDts).format("L"));
            $("#ExpireDate").text(moment(result.ExpiresDts).format("L"));
            $("#LastUpdate").text(moment(result.LastUpdateDts).format("L"));
            $("#LastUpdatedBy").text(result.LastUpdateNt);
            $("#ProcessIn").text(result.ProcessIn);
        }
        );
        return false;
    }
    

    Setting up localization is as easy as adding configuration files (you get them at momentjs.com) to your project and configuring the language:

    moment.lang('de');
    

提交回复
热议问题