jqurey 將如2017-5-30轉化為時間戳或者時間戳轉化為日期的js方法
阿新 • • 發佈:2017-05-31
jqurey 將如2017-5-30轉化為時間戳或者時間戳轉化為日期的js方法 }
function unix_to_datetime(unix) {
var now = new Date(parseInt(unix) * 1000);
return now.toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}
</script>
<script>
function datetime_to_unix(datetime){
var tmp_datetime = datetime.replace(/:/g,‘-‘);
tmp_datetime = tmp_datetime.replace(/ /g,‘-‘);
var arr = tmp_datetime.split("-");
var now = new Date(Date.UTC(arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5]));
return parseInt(now.getTime()/1000);
function unix_to_datetime(unix) {
var now = new Date(parseInt(unix) * 1000);
return now.toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}
</script>
本文出自 “高山” 博客,謝絕轉載!
jqurey 將如2017-5-30轉化為時間戳或者時間戳轉化為日期的js方法