1. 時間変換タイムスタンプ
次のようにコードをコピーします。
関数transdate(endTime){
var date=新しい日付();
date.setFull Year(endTime.substring(0,4));
date.setMonth(endTime.substring(5,7)-1);
date.setDate(endTime.substring(8,10));
date.setHours(endTime.substring(11,13));
date.setMinutes(endTime.substring(14,16));
date.setSeconds(endTime.substring(17,19));
Date.parse(date)/1000 を返します。
}
2. タイムスタンプの変換時間
(1): 2011-3-16 16:50:43 形式に変換:
次のようにコードをコピーします。
関数 getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ")
戻ります。
}
(2):2011年3月16日16時50分43秒に変換:
次のようにコードをコピーします。
関数 getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString()
戻ります。
}
(3):2011年3月16日16時50分に換算
次のようにコードをコピーします。
関数 getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString().substr(0,16);
戻ります。
}