方法:通過日期函數toLocaleString()獲取。new Date().toLocaleString( ); //"2019/9/1 上午11:20:23"
獲取年月日方法:new Date().toLocaleString( ).replace(/\//g,'-').split(" ")[0]; //"2019-9-1"
toLocaleString() 方法可根據本地時間把 Date 對象轉換為字符串,並返回結果。
方法:通過日期函數toLocaleString()獲取。new Date().toLocaleString( ); //"2019/9/1 上午11:20:23"
獲取年月日方法:new Date().toLocaleString( ).replace(/\//g,'-').split(" ")[0]; //"2019-9-1"
toLocaleString() 方法可根據本地時間把 Date 對象轉換為字符串,並返回結果。
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。