公司项目需要获取时间并且转换格式,之前没有实现过但读过源码,新来的小哥给我讲了下细节.算是学到了..... function getLocalTime(){ var now=new Date(); var year=now.getFullYear(); var moth=now.getMonth()+1; if(month<10){ moth="0"+month; } var date=now.getDate(); if(date<10){ date="0&quo
一.时间转换时间戳 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
ColourClock 将时间值转换成背景色 https://github.com/bennyguitar/ColourClock This project converts Time to Hex/RGB, and is quite beautiful to look at. This was HEAVILY inspired byhttp://thecolourclock.co.uk and really, all credit goes to them. 这个工程是用来把时间值转换为Hex