首页 > IT职业 > IT职场 > js 转换时间戳的写法Script
摘要:自带方法vartime=newDate(毫秒)函数加正则functiongetLocalTime(nS){returnnewDate(parseInt(nS)*1000).toLocaleString().replace(/:/d{1,2}$/,'');}alert(getLocalTime(1293072805));3.自定义时间格式的方法(可自定义时间格式)functionchangeDateFormat(cellval){if(cellval!=null){vardat
var time= new Date(毫秒)function getLocalTime(nS) { return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:/d{1,2}$/,' '); } alert(getLocalTime(1293072805));
3.自定义时间格式的方法(可自定义时间格式)
function changeDateFormat(cellval) { if (cellval != null) { var date = new Date(cellval); var month = date.getMonth() + 1
4.大神写法(高度自定义)
// 转换时间戳 var format = function (time, format) { var t = new Date(毫秒); var tf = function (i) { return (i
函数加正则
自带方法
原文链接:https://www.aliyun.com/jiaocheng/975822.html?spm=5176.100033.9.5.LP0zJ2
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3549/viewspace-2811564/ ,如需转载,请注明出处,否则将追究法律责任。