标签:style class blog code color get
<script> function js_strto_time(str_time){ var new_str = str_time.replace(/:/g,‘-‘); new_str = new_str.replace(/ /g,‘-‘); var arr = new_str.split("-"); var datum = new Date(Date.UTC(arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5])); return strtotime = datum.getTime()/1000; } function js_date_time(unixtime) { var timestr = new Date(parseInt(unixtime) * 1000); var datetime = timestr.toLocaleString().replace(/年|月/g, "-").replace(/日/g, " "); return datetime; } var str_time = ‘2012-04-19 16:00:00‘; var rst_strto_time = js_strto_time(str_time)); document.write("<br><b>转换后的UNIX时间戳为</b>: "+rst_strto_time); var unixstr = js_strto_time(str_time); var rst_date_time = js_date_time(unixstr); document.write("<br><b>转换后的日期为</b>: "+rst_date_time); </script>
标签:style class blog code color get
原文地址:http://www.cnblogs.com/scrit/p/3804361.html