Maison  >  Article  >  interface Web  >  json 日期数据转成日期字符串

json 日期数据转成日期字符串

巴扎黑
巴扎黑original
2016-11-25 14:12:591216parcourir

   function ChangeDateFormat(jsondate) {  

            jsondate = jsondate.replace("/Date(", "").replace(")/", "");  

              

            if (jsondate.indexOf("+") > 0) {  

                jsondate = jsondate.substring(0, jsondate.indexOf("+"));  

            } else if (jsondate.indexOf("-") > 0) {  

                jsondate = jsondate.substring(0, jsondate.indexOf("-"));  

            }  

            //alert(jsondate);  

            var date = new Date(parseInt(jsondate, 10));  

            //alert(date.getHours());  

            var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;  

            var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();  


            return date.getFullYear() + "-" + month + "-" + currentDate ;


        }  


Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn