js轉換數據庫中DateTime字段類型


在程序中,從數據庫中讀取到的日期時間類型數據一般是這種格式:"/Date(1355109408000+0800)/"

要經過js函數處理變為格式:'2012-12-10 11:05:21'

用此js函數即可搞定:

function timeFormatter(value) {

    var da = new Date(parseInt(value.replace("/Date(", "").replace(")/" , "").split( "+")[0]));

    return da.getFullYear() + "-" + (da.getMonth() + 1) + "-" + da.getDate() + " " + da.getHours() + ":" + da.getMinutes() + ":" + da.getSeconds();

}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM