js时间戳转化为时间 //时间戳转时间 function time(sj) { var now = new Date(sj*1000); var year =now.getFullYear(); var month =now.getMonth()+1; var date =now.getDate(); var hour =now.getHours(); var minute =now.getMinutes(); var second =now.getSeconds(); return year+
一.时间转换时间戳 var date = new Date(); //时间对象 var str = date.getTime(); //转换成时间戳 二.时间戳转换为时间 1.转换成形如 2018年1月4日 14:00:00 格式: function getDate(date){ var t = new Date(date).toLocaleString(); return t; } 2.还可以这样 // 也很简单 var strtime = '2014-04-23 18
这里是在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