这里是在mac下的操作,主要就是用date这个命令,更多的用法用man命令查看 字符串格式时间 TO 时间戳我们知道date 命令可以直接把当前时间转化为时间戳 # date +%s1436781527 linux下不支持自定义的格式转化为实践戳, 下面几种可以 $ date -d '06/12/2018 07:21:22' +"%s"1528759282$ date -d '2018-06-12 07:21:22' +"%s"1528759282$ date -d…
1.当前时间换时间戳 var timestamp = parseInt(new Date().getTime()/1000); // 当前时间戳 document.write(timestamp); 2.当前时间换日期字符串 var now = new Date(); var yy = now.getFullYear(); //年 var mm = now.getMonth() + 1; //月 var dd = now.getDate(); //日 var hh = now.getHours(…