JS 日期轉爲 時間戳格式

如果日期爲2015年04月29日或者2015-04-29格式時。js是不認識‘年、月、日’和’-‘的。所以要先把符號轉爲"/"

                        var str = "2015年04月29日";
                        str = str.replace(/年/g,'/');
			str = str.replace(/月/g,'/');
			str = str.replace(/日/g,'');
			var date = new Date(str);
			content=date.getTime();
			alert(content);
			//結果爲時間戳


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章