Date 类型一些专门用于将日期格式化为字符串的方法:
toDateString()——以特定于实现的格式显示星期几、月、日和年
toTimeString()——以特定于实现的格式显示时、分、秒和时区
toLocaleDateString()——以特定于地区的格式显示星期几、月、日和年
toLocaleTimeString()——以特定于实现的格式显示时、分、秒toUTCString()——以特定于实现的格式完整的UTC 日期
new Date().toLocaleString() //"2017/4/5 下午3:00:10" new Date().toDateString() //"Wed Apr 05 2017" new Date().toTimeString() //"15:03:31 GMT+0800 (中国标准时间)" new Date().toLocaleTimeString() //"下午3:04:06" new Date().toLocaleDateString() //"2017/4/5" new Date().toUTCString() //"Wed, 05 Apr 2017 07:04:36 GMT"