DateTime to javascript date

前端 未结 10 1487
忘掉有多难
忘掉有多难 2020-11-28 05:40

From another answer on Stackoverflow is a conversion from Javascript date to .net DateTime:

long msSinceEpoch = 1260402952906; // Value from Date.getTime() i         


        
10条回答
  •  一个人的身影
    2020-11-28 05:57

    You can try this in your Action:

    return DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
    

    And this in your Ajax success:

    success: function (resultDateString) {
        var date = new Date(resultDateString);
    }
    

    Or this in your View: (Javascript plus C#)

    var date = new Date('@DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss")');
    

提交回复
热议问题