<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript">// 获取当前时间戳(以s为单位)var timestamp = Date.parse(new Date()); timestamp = timestamp / 1000;//当前时间戳为:1403149534console.log("当前时间戳为:" + timestamp);// 获取某个时间格式的时间戳var stringTime = "2014-07-10 10:21:12";var timestamp2 = Date.parse(new Date(stringTime)); timestamp2 = timestamp2 / 1000;//2014-07-10 10:21:12的时间戳为:1404958872 console.log(stringTime + "的时间戳为:" + timestamp2);// 将当前时间换成时间格式字符串var timestamp3 = 1403058804;var newDate = new Date(); newDate.setTime(timestamp3 * 1000);// Wed Jun 18 2014 console.log(newDate.toDateString());// Wed, 18 Jun 2014 02:33:24 GMT console.log(newDate.toGMTString());// 2014-06-18T02:33:24.000Zconsole.log(newDate.toISOString());// 2014-06-18T02:33:24.000Z console.log(newDate.toJSON());// 2014年6月18日 console.log(newDate.toLocaleDateString());// 2014年6月18日 上午10:33:24 console.log(newDate.toLocaleString());// 上午10:33:24 console.log(newDate.toLocaleTimeString());// Wed Jun 18 2014 10:33:24 GMT+0800 (中国标准时间)console.log(newDate.toString());// 10:33:24 GMT+0800 (中国标准时间) console.log(newDate.toTimeString());// Wed, 18 Jun 2014 02:33:24 GMTconsole.log(newDate.toUTCString()); Date.prototype.format = function(format) { var date = { "M+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours(), "m+": this.getMinutes(), "s+": this.getSeconds(), "q+": Math.floor((this.getMonth() + 3) / 3), "S+": this.getMilliseconds() }; if (/(y+)/i.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)); } for (var k in date) { if (new RegExp("(" + k + ")").test(format)) { format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? date[k] : ("00" + date[k]).substr(("" + date[k]).length)); } } return format; } console.log(newDate.format('yyyy-MM-dd h:m:s'));</script>
javascript时间戳和日期字符串相互转换
-
Spring Shiro 使用默认的Session会话管理
项目中用到了shiro session会话管理机制,今天来总结一下,以下都是在spring boot框架实现。 shiro的session管理机制很完善,也是独立于j2ee容器且不依赖的,所以我们完全可以使用shiro提供给我们的session会话管理来实现我们的业务逻辑,默认提供的sessionDAO是memorySessionDAO,这里也主要讲它的配置和原理。 首先来看下如何在spring boot下配置默认的session会话管理: ShiroConfig类:
-
ServletRequest获取token,获取header
把ServletRequest转化为HttpServletRequest,就好获得了
-
intellij,idea,git for windows一直占用,内存过高
fatal: Unable to create,git/index.lock': File exists.
-
consola 教程
consola 和 console 只差一个字母,并且它们都是控制器日志输出的好帮手。console 在某些方面,使用有些局限性。consola 是一个功能更丰富,更漂亮的控制台日志输出控件。今天我们一起来学习它的
-
AndroidStudio 多层级 Module 对 aar 引用问题
有个arr文件被放到Module A中引用,现在Module B又依赖了Module A,则在编译过程中会发生错误,Module B找不到aar文件。
-
nginx支持socket
安装nginx,stream模块默认不安装的,需要手动添加参数:–with-stream,根据自己系统版本选择nginx1.9或以上版本。
-
Java中List转换为数组,数组转List
List转换为Array可以这样处理,反过来,如果要将数组转成List怎么办呢
-
git合并时冲突<<<<<<< HEAD
head 到 =======里面的lalala是自己的commit的内容 =========到 >>>>>>里面的hehehe是下拉的内容
-
Java中数组怎么深度复制
有时候循环进行一些操作,放入list,发现,list中的数据都是一个数据,这就尴尬了,我们需要深度复制,才能解决这个问题。或者生成新的,也就是深度复制。
-
static inner class和非static inner class的实例化问题(can only instantiate non-static inner class...)
non-static inner class 需要持有外部类实例的引用,所以无法直接调用构造器创建,需要先构造外部类实例,然后通过外部类实例调用构造方法创建,如下: