获取当前时间,并将时间格式脚本//时间戳设置为格式functionformatdate(datetime ) vardate=new date (date ) datetime ) /时间戳设置为10位) 1000 var year=date.getFullYear () varmonth=(0) date.getmonth ) (1) ).slice )-2 ) varsdate=)0)0var hououe nutes ) ).slice )-2 ) varsecond拼接varresult=year '-' month '-' sdate ' ' hour ' : ' minute ' : ' second/获取当前时间var date=new date console.log (date ) /当前时间戳var dateTime=date.getTime ) (console.log ) datetime ) /使用上述函数