2017-03-11 1 views
1

私の時間形式を好きではない、それは次のようになります。TS「2017年3月11日午前0時00分00秒」Moment.jsは、私はJSONからSQLの日付を返しています

私がしようmoment.js書式を適用、私はこのエラーが発生します:

Deprecation warning: value provided is not in a recognized ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non ISO date formats are discouraged and will be removed in an upcoming major release.

どのように私はこの問題を解決することができますか?

<script> 
    function PopulateReviewTimeStamps() { 
    // Populate timestamp data div 
    console.log("Review timestamp CFC called"); 
    $.ajax({ 
     url: 'cfcs/reviewdata.cfc?method=getTimeStampData&returnformat=json', 
     data: { 
     ticket_id: $("##ticket_id").attr("Value") 
     }, 
     success: function(response) { 
     console.log("success function called"); 
     var value = response; 
     var datetime = moment(value); 
     var date = datetime.format('MMMM Do, YYYY'); 
     var time = datetime.format('h:mma'); 


     // append new option to list 
     console.log("about to change div" + value); 
     $('##sentDate').html(date + " at " + time); 


     // PopulateOdometers(); 
     }, 
     error: function(msg) { 
     console.log("Something went wrong with populating stats function"); 
     } 
    }) 
    } 
</script> 

UPDATE:私はAJAXリクエストから変更 はタイプ "日付" を返すように

は、ここに私のコードです。私はもはや無効な日付を受け取ることはありませんが、私の日付は2000年11月5日12:00に表示されます。

次のようにコンソールログは次のとおりです。 のorignal日付値:11月5日:moments.js前に3月11 2017〇時00分00秒-0500 < -----はにdiv要素を変更しようと

を実行しています、200012:00am <は----- moments.jsが

+0

[あなたの日付形式のパス 'モーメント()'パターン。](https://momentjs.com/docs/#/parsing/string-format/) – Pointy

+0

実際に値に 'ts'とそれらの一重引用符が含まれていますか? – JLRishe

+0

私のDBは次のように格納されています:2017-03-10 00:00:00 しかし、console.logは次のように表示します:div {ts '2017-03-11 00:00:00'} –

答えて

関連する問題