当前位置: 首页 > 编程日记 > 正文

将时间改为显示:几天前,几小时前,或者几分钟前

(原博客地址:http://blog.csdn.net/kenhins/article/details/38010811)

方法一:

个人做法是保存时间戳,然后在前端用jq插件做转换,比如 smart-time-ago

-----------------------------------------------

方法二:

(通过freemarker模板)如果用freemarker模板可以这样写,别的模板类推

根据自己的意愿修改条件和输出,把你的datetime传进去即可

<#macro timeline_dt datetime=.now>
<#assign ct = (.now?long-datetime?long)/1000>
<#if ct gte 31104000><#--n年前-->${(ct/31104000)?int}年前<#t><#elseif ct gte 2592000><#--n月前-->${(ct/2592000)?int}个月前<#t><#elseif ct gte 86400*2><#--n天前-->${(ct/86400)?int}天前<#t><#elseif ct gte 86400><#--1天前-->昨天<#t><#elseif ct gte 3600><#--n小时前-->${(ct/3600)?int}小时前<#t><#elseif ct gte 60><#--n分钟前-->${(ct/60)?int}分钟前<#t><#elseif ct gt 0><#--n秒前-->${ct?int}秒前<#t><#else>刚刚
</#if>
</#macro>

------------------------------------------------------------

方法三:

找到一个专门的插件PrettyTime

public static void main(String[] args) {PrettyTime p = new PrettyTime();System.out.println(p.format(DateUtils.addDays(new Date(), 2)));}

-----------------------------------------------------------------

方法四:

自定义Java方法:

private final static long minute = 60 * 1000;// 1分钟private final static long hour = 60 * minute;// 1小时private final static long day = 24 * hour;// 1天private final static long month = 31 * day;//private final static long year = 12 * month;///*** 返回文字描述的日期* * @param date* @return*/public static String getTimeFormatText(Date date) {if (date == null) {return null;}long diff = new Date().getTime() - date.getTime();long r = 0;if (diff > year) {r = (diff / year);return r + "年前";}if (diff > month) {r = (diff / month);return r + "个月前";}if (diff > day) {r = (diff / day);return r + "天前";}if (diff > hour) {r = (diff / hour);return r + "个小时前";}if (diff > minute) {r = (diff / minute);return r + "分钟前";}return "刚刚";}

-------------------------------------------------------------------------------------------------------

方法五:

使用js插件:(原版的timeago.js)

插件描述:timeago.js是一款基于jQuery的时间处理插件,它可以轻易的将时间戳转换成如:5分钟前,约3小时前这样的更友好易读的时间轴

查看演示文档:http://www.jq22.com/jquery-info5468

// Smart Time Ago v0.1.0// Copyright 2012, Terry Tai, Pragmatic.ly
// https://pragmatic.ly/
// Licensed under the MIT license.
// https://github.com/pragmaticly/smart-time-ago/blob/master/LICENSE(function() {var TimeAgo;TimeAgo = (function() {function TimeAgo(element, options) {this.startInterval = 60000;this.init(element, options);}TimeAgo.prototype.init = function(element, options) {this.$element = $(element);this.options = $.extend({}, $.fn.timeago.defaults, options);this.updateTime();return this.startTimer();};TimeAgo.prototype.startTimer = function() {var self;self = this;return this.interval = setInterval((function() {return self.refresh();}), this.startInterval);};TimeAgo.prototype.stopTimer = function() {return clearInterval(this.interval);};TimeAgo.prototype.restartTimer = function() {this.stopTimer();return this.startTimer();};TimeAgo.prototype.refresh = function() {this.updateTime();return this.updateInterval();};TimeAgo.prototype.updateTime = function() {var self;self = this;return this.$element.findAndSelf(this.options.selector).each(function() {var timeAgoInWords;timeAgoInWords = self.timeAgoInWords($(this).attr(self.options.attr));return $(this).html(timeAgoInWords);});};TimeAgo.prototype.updateInterval = function() {var filter, newestTime, newestTimeInMinutes, newestTimeSrc;if (this.$element.findAndSelf(this.options.selector).length > 0) {if (this.options.dir === "up") {filter = ":first";} else if (this.options.dir === "down") {filter = ":last";}newestTimeSrc = this.$element.findAndSelf(this.options.selector).filter(filter).attr(this.options.attr);newestTime = this.parse(newestTimeSrc);newestTimeInMinutes = this.getTimeDistanceInMinutes(newestTime);if (newestTimeInMinutes >= 0 && newestTimeInMinutes <= 44 && this.startInterval !== 60000) {this.startInterval = 60000;return this.restartTimer();} else if (newestTimeInMinutes >= 45 && newestTimeInMinutes <= 89 && this.startInterval !== 60000 * 22) {this.startInterval = 60000 * 22;return this.restartTimer();} else if (newestTimeInMinutes >= 90 && newestTimeInMinutes <= 2519 && this.startInterval !== 60000 * 30) {this.startInterval = 60000 * 30;return this.restartTimer();} else if (newestTimeInMinutes >= 2520 && this.startInterval !== 60000 * 60 * 12) {this.startInterval = 60000 * 60 * 12;return this.restartTimer();}}};TimeAgo.prototype.timeAgoInWords = function(timeString) {var absolutTime;absolutTime = this.parse(timeString);return this.distanceOfTimeInWords(absolutTime) + (this.options.lang.suffix);};TimeAgo.prototype.parse = function(iso8601) {var timeStr;timeStr = $.trim(iso8601);timeStr = timeStr.replace(/\.\d\d\d+/, "");timeStr = timeStr.replace(/-/, "/").replace(/-/, "/");timeStr = timeStr.replace(/T/, " ").replace(/Z/, " UTC");timeStr = timeStr.replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2");return new Date(timeStr);};TimeAgo.prototype.getTimeDistanceInMinutes = function(absolutTime) {var timeDistance;timeDistance = new Date().getTime() - absolutTime.getTime();return Math.round((Math.abs(timeDistance) / 1000) / 60);};TimeAgo.prototype.distanceOfTimeInWords = function(absolutTime) {var dim;dim = this.getTimeDistanceInMinutes(absolutTime);if (dim === 0) {return "" + this.options.lang.prefixes.lt + " " + this.options.lang.units.minute;} else if (dim === 1) {return "1 " + this.options.lang.units.minute;} else if (dim >= 2 && dim <= 44) {return "" + dim + " " + this.options.lang.units.minutes;} else if (dim >= 45 && dim <= 89) {return "" + this.options.lang.prefixes.about + " 1 " + this.options.lang.units.hour;} else if (dim >= 90 && dim <= 1439) {return "" + this.options.lang.prefixes.about + " " + (Math.round(dim / 60)) + " " + this.options.lang.units.hours;} else if (dim >= 1440 && dim <= 2519) {return "1 " + this.options.lang.units.day;} else if (dim >= 2520 && dim <= 43199) {return "" + (Math.round(dim / 1440)) + " " + this.options.lang.units.days;} else if (dim >= 43200 && dim <= 86399) {return "" + this.options.lang.prefixes.about + " 1 " + this.options.lang.units.month;} else if (dim >= 86400 && dim <= 525599) {return "" + (Math.round(dim / 43200)) + " " + this.options.lang.units.months;} else if (dim >= 525600 && dim <= 655199) {return "" + this.options.lang.prefixes.about + " 1 " + this.options.lang.units.year;} else if (dim >= 655200 && dim <= 914399) {return "" + this.options.lang.prefixes.over + " 1 " + this.options.lang.units.year;} else if (dim >= 914400 && dim <= 1051199) {return "" + this.options.lang.prefixes.almost + " 2 " + this.options.lang.units.years;} else {return "" + this.options.lang.prefixes.about + " " + (Math.round(dim / 525600)) + " " + this.options.lang.units.years;}};return TimeAgo;})();$.fn.timeago = function(options) {if (options == null) options = {};return this.each(function() {var $this, data;$this = $(this);data = $this.data("timeago");if (!data) $this.data("timeago", new TimeAgo(this, options));if (typeof options === 'string') return data[options]();});};$.fn.findAndSelf = function(selector) {return this.find(selector).add(this.filter(selector));};$.fn.timeago.Constructor = TimeAgo;$.fn.timeago.defaults = {selector: 'time.timeago',attr: 'datetime',dir: 'up',lang: {units: {second: "second",seconds: "seconds",minute: "minute",minutes: "minutes",hour: "hour",hours: "hours",day: "day",days: "days",month: "month",months: "months",year: "year",years: "years"},prefixes: {lt: "less than a",about: "about",over: "over",almost: "almost"},suffix: ' ago'}};}).call(this);

使用js插件:(改装版(简哟版)timeago.js)中文的

(function (factory) {if (typeof define === 'function' && define.amd) {// AMD. Register as an anonymous module.define(['jquery'], factory);} else {// Browser globals
    factory(jQuery);}
}(function ($) {$.timeago = function(timestamp) {if (timestamp instanceof Date) {return inWords(timestamp);} else if (typeof timestamp === "string") {return inWords($.timeago.parse(timestamp));} else if (typeof timestamp === "number") {return inWords(new Date(timestamp));} else {return inWords($.timeago.datetime(timestamp));}};var $t = $.timeago;$.extend($.timeago, {settings: {refreshMillis: 60000,allowFuture: false,localeTitle: false,cutoff: 0,strings: {prefixAgo: null,prefixFromNow: null,suffixAgo: "前",suffixFromNow: "from now",seconds: "1分钟",minute: "1分钟",minutes: "%d分钟",hour: "1小时",hours: "%d小时",day: "1天",days: "%d天",month: "1月",months: "%d月",year: "1年",years: "%d年",wordSeparator: "",numbers: []}},inWords: function(distanceMillis) {var $l = this.settings.strings;var prefix = $l.prefixAgo;var suffix = $l.suffixAgo;if (this.settings.allowFuture) {if (distanceMillis < 0) {prefix = $l.prefixFromNow;suffix = $l.suffixFromNow;}}var seconds = Math.abs(distanceMillis) / 1000;var minutes = seconds / 60;var hours = minutes / 60;var days = hours / 24;var years = days / 365;function substitute(stringOrFunction, number) {var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;var value = ($l.numbers && $l.numbers[number]) || number;return string.replace(/%d/i, value);}var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||seconds < 90 && substitute($l.minute, 1) ||minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||minutes < 90 && substitute($l.hour, 1) ||hours < 24 && substitute($l.hours, Math.round(hours)) ||hours < 42 && substitute($l.day, 1) ||days < 30 && substitute($l.days, Math.round(days)) ||days < 45 && substitute($l.month, 1) ||days < 365 && substitute($l.months, Math.round(days / 30)) ||years < 1.5 && substitute($l.year, 1) ||substitute($l.years, Math.round(years));var separator = $l.wordSeparator || "";if ($l.wordSeparator === undefined) { separator = " "; }return $.trim([prefix, words, suffix].join(separator));},parse: function(iso8601) {var s = $.trim(iso8601);s = s.replace(/\.\d+/,""); // remove millisecondss = s.replace(/-/,"/").replace(/-/,"/");s = s.replace(/T/," ").replace(/Z/," UTC");s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400return new Date(s);},datetime: function(elem) {var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");return $t.parse(iso8601);},isTime: function(elem) {// jQuery's `is()` doesn't play well with HTML5 in IEreturn $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
    }});// functions that can be called via $(el).timeago('action')// init is default when no action is given// functions are called with context of a single elementvar functions = {init: function(){var refresh_el = $.proxy(refresh, this);refresh_el();var $s = $t.settings;if ($s.refreshMillis > 0) {setInterval(refresh_el, $s.refreshMillis);}},update: function(time){$(this).data('timeago', { datetime: $t.parse(time) });refresh.apply(this);},updateFromDOM: function(){$(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });refresh.apply(this);}};$.fn.timeago = function(action, options) {var fn = action ? functions[action] : functions.init;if(!fn){throw new Error("Unknown function name '"+ action +"' for timeago");}// each over objects here and call the requested functionthis.each(function(){fn.call(this, options);});return this;};function refresh() {var data = prepareData(this);var $s = $t.settings;if (!isNaN(data.datetime)) {if ( $s.cutoff == 0 || distance(data.datetime) < $s.cutoff) {$(this).text(inWords(data.datetime));}}return this;}function prepareData(element) {element = $(element);if (!element.data("timeago")) {element.data("timeago", { datetime: $t.datetime(element) });var text = $.trim(element.text());if ($t.settings.localeTitle) {element.attr("title", element.data('timeago').datetime.toLocaleString());} else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {element.attr("title", text);}}return element.data("timeago");}function inWords(date) {return $t.inWords(distance(date));}function distance(date) {return (new Date().getTime() - date.getTime());}// fix for IE6 suckagedocument.createElement("abbr");document.createElement("time");
}));

具体使用方法:

HTML

首先需要载入jQuery库和timeago.js

<script type="text/javascript" src="jquery.js"></script> 
<script type="text/javascript" src="jquery.timeago.js"></script>

接着我们在页面中加入以下代码:

<abbr class="timeago" title="2012-11-28T11:17:00Z"></abbr>

我们给abbr元素设置class为timeago,设置title为标准的ISO 8601时间格式,你也可以使用html5标签time:

<time class="timeago" datetime="2012-12-10T02:20:50Z"></time>

jQuery

使用jQuery调用timeago(),运行页面即可看到效果。

$(function(){ $(".timeago").timeago(); 
});

以下方法也可以调用timeago():

$(function(){ jQuery.timeago(new Date());             //=> "约1分钟前" jQuery.timeago("2012-12-09");            //=> "1天前" jQuery.timeago(jQuery("abbr#some_id"));       //=> "1年前" // [title="2011-11-20"] 
});

timeago.js还支持处理将来的时间,如“3天后”,只需将以下参数设置为true。

jQuery.timeago.settings.allowFuture = true;

补充说明

timeago.js在标准的UTC时间模式下运行,对于我们处在东八区(+08:00),可以在加载时间时减去8小时,或者在时间格式中使用+08:00来显示准确的北京时间。

举个栗子,假设要处理的是北京时间2012-12-10 18:02:45,那么可以通过以下方式来获取准确的北京时间。

<!--先减去8小时--> 
<abbr class="timeago" title="2012-12-10T10:02:45Z"></abbr> 
<!--在时间后+08:00--> 
<abbr class="timeago" title="2012-12-10T18:02:45Z+08:00"></abbr>

转载于:https://www.cnblogs.com/CassieHouse/p/5849012.html

相关文章:

支持placeholder和自适配高度的TextView控件

一.应用于项目的效果如下&#xff1a; 二.使用方法&#xff1a; 1.导入JXTextView.h头文件 2.初始化,并添加到view中&#xff1a; JXTextView *textView [[JXTextView alloc] initWithFrame:CGRectMake(10, 10, 200, 30)];textView.placeholder "请输入内容";tex…

ZOJ 3735 dp

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode3735 好久没做DP题了&#xff0c;一开始没理解题目里的C(M,3)是干什么&#xff0c;原来就是组合&#xff0c;C M 取3&#xff0c;就等于n*&#xff08;n-1&#xff09;*&#xff08;n-2&#xff09;/6;题目里还有…

haproxy实现高可用及负载均衡

Haproxy简介&#xff1a; Haproxy是一个使用c语言编写的自由开发源代码软件&#xff0c;它提供高可用性、负载均衡、以及基于http和tcp的应用程序代理。Haproxy特别使用于那些负载特别大的web站点。Haproxy运行在当前的硬件上&#xff0c;完全可以支持数以万计的并发连接&#…

Apache转发到Tomcat

#vi /etc/httpd/conf/httpd.conf 添加下面配置 NameVirtualHost *:80 <VirtualHost *:80>ProxyPreserveHost OnServerName www.域名.comProxyPass / http://www.域名.com:8080/system/ErrorLog logs/error_logCustomLog logs/access_log common</VirtualHost> 作者…

.net基础问题

string sqlstr "select BranchCode,BranchName from t_sys_Branch where Jglx_DataDm{0} and IsVisible1"; sqlstr string.Format(sqlstr, departType); 上述代码运行之后 sqlstr"select BranchCode,BranchName from t_sys_Branch where Jglx_DataDmdepartTyp…

【iOS】NSDate分类,获得中国农历

1.说明&#xff1a; 参考网上代码写的一个分类&#xff0c;只需一句代码就可得到NSDate对象所对应的中国农历、星期。 2.使用方法&#xff1a; &#xff08;1&#xff09;导入分类头文件&#xff1a; #import "NSDateChineseDate.h"&#xff08;2&#xff09;NSDat…

LVS_NAT实现负载均衡

简介&#xff1a; 基于NAT机制实现。当用户请求到达director之后&#xff0c;director将请求报文的目标地址(即VIP)改成选定的realserver地址&#xff0c;同时将报文的目标端口也改成选定的realserver的相应端口&#xff0c;最后将报文请求发送到指定的realserver&#xff1b;…

自定义Push和Pop过渡动画

一、效果和源码 本文介绍如何实现一个NavigationController的自定义Push和Pop过渡动画&#xff0c;运行效果如下&#xff1a; 源码&#xff1a;https://github.com/dolacmeng/TransitionDemo 或http://download.csdn.net/detail/dolacmeng/9572384二、准备工作 首先&#xff0…

centos 安装 mysql 5.7

一&#xff0c;wget http://dev.mysql.com/get/mysql57-community-release-el6-8.noarch.rpm 二&#xff0c;yum localinstall mysql57-community-release-el6-8.noarch.rpm 三&#xff0c;yum install mysql-server 四&#xff0c;mysqld --initialize --usermysql 五&#xf…

c语言:婚礼上的谎言

/* 三对新人参加婚礼&#xff0c;三位新郎A,B,C,三位新娘X,Y,Z。 有人想知道谁与谁结婚&#xff0c;于是就问他们&#xff1a; A说他将和X结婚&#xff1b; X说他的未婚夫是C&#xff1b; C说他将和Z结婚。 这人时候知道他们都在说谎。编程求谁与谁结婚&#xff01; */ /* 思路…

redis主从复制、高可用和集群

redis简介&#xff1a; redis是一个key-value存储系统.和Memcached类似&#xff0c;它支持存储的value类型相对更多&#xff0c;包括string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和hashs&#xff08;哈希类型&#xff09;;这些数据类型都支持push/pop、…

对学习编译原理的看法

我认为编译原理这本书是一门与代码做斗争的课程&#xff0c;学习编译原理能够追寻程序设计语言的本质&#xff0c;了解计算机各种语言编译的原理。学习了编译原理能够更加深入的了解计算机各种高级语言使用的原理&#xff0c;能使自己更加容易更加好的学习好程序语言&#xff0…

iOS提示气泡,带动画

1.效果如图&#xff1a; 从项目中抠出来的&#xff0c;做了简单的封装。 2.用法&#xff1a; //顶部提示HYNoticeView *noticeTop [[HYNoticeView alloc] initWithFrame:CGRectMake(50, 66, 250, 40) text:"这里可以查询全城婚礼人的档期哦&#xff01;" position:…

GIt/Github常用命令

1&#xff09;git init:初始化本地仓库 2&#xff09;创建文件&#xff1a;touch read.txt 3&#xff09;当操作本地的文件时&#xff0c;使用常用的命令&#xff0c;如&#xff08;mv&#xff0c;ls。。&#xff09;就可以操作&#xff0c;当操作暂存区的文件时需要在命令前家…

python练习题(python之“求一个数的阶乘并求结果中从后向前数第一个不为0(零)的数” 等)

实验环境&#xff1a;python2.7 题目1&#xff1a;python之“求一个数的阶乘并求结果中从后向前数第一个不为0(零)的数”程序&#xff1a; import math def factorial(n): #定义一个函数&#xff0c;返回一个数的阶乘 if n0: return 1 else: sumn*factorial(n-…

【动画1】UIView动画

讲一下动画。将分为以下5篇博客。 一&#xff09;UIView动画 二&#xff09;Layer动画 三&#xff09;3D动画 四&#xff09;转场动画 五&#xff09;第三方动画框架 相关代码&#xff1a;https://github.com/dolacmeng/AnimationDemo 参考资料&#xff1a;iOS Animation…

【python】解压文件

参考&#xff1a;http://essen.iteye.com/blog/1941489 tarfile模块 具体使用方法&#xff1a; https://docs.python.org/2/library/tarfile.html 例子&#xff1a;一次性解压所有文件 import tarfilet tarfile.open("abc.tgz", "r:gz")t.extractall(path…

JS设计模式——3.封装与信息隐藏

封装、信息隐藏与接口的关系 信息隐藏是目的&#xff0c;封装是手段。 接口提供了一份记载着可供公共访问的方法的契约。它定义了两个对象间可以具有的关系。只要接口不变&#xff0c;这个关系的双方都是可以替换的。 一个理想的软件系统应该为所有类定义接口。 创建对象的基本…

nginx源码编译、负载均衡及模块的扩展

1、nginx源码编译 实验环境&#xff1a; iptables和selinux关闭 redhat6.5 nginx&#xff1a;test1: 172.25.1.11 [roottest1 ~]# ls nginx-1.14.0.tar.gz [roottest1 ~]# tar zxf nginx-1.14.0.tar.gz [roottest1 ~]# useradd -s /sbin/nologin nginx [roottest1 ~]# i…

LinkedHashMap and LinkedHashSet

LinkedHashMap实现了Map接口&#xff0c;是HashMap的直接子类&#xff0c;它同时满足HashMap和linked list的某些特性。可将LinkedHashMap看作采用linked list增强的HashMap。 LinkedHashMap在HashMap的基础上&#xff0c;采用双向链表&#xff08;doubly-linked list&#xff…

Windows Phone开发(19):三维透视效果

Windows Phone开发&#xff08;19&#xff09;&#xff1a;三维透视效果 原文:Windows Phone开发&#xff08;19&#xff09;&#xff1a;三维透视效果 三维效果也可以叫透视效果&#xff0c;所以&#xff0c;我干脆叫三维透视效果。理论知识少讲&#xff0c;直接用例开场吧&am…

【动画2】CALayer动画

一&#xff09;UIView动画 二&#xff09;CoreAnimation动画 前言&#xff1a;上一篇已经介绍了UIKit给我们封装好的UIView动画的使用&#xff0c;UIKit动画是建立在CoreAnimation动画之上的&#xff0c;CoreAnimation是直接作用于CALayer上而非UIView。一、CoreAnimation动画…

nginx+tomcat+memcache实现负载均衡、session共享

实验架构图&#xff1a; Table of Contents 1、配置tomcat 2、安装memcache 3、查看tomcat和memcache是否配置好 4、nginx实现负载均衡&#xff1a; 5、客户端进行测试&#xff1a; 6、验证结论&#xff1a; 7、总结&#xff1a; 实验环境&#xff1a; linux redhat6.…

(转)二叉树系列面试问题

转自 &#xff1a;http://blog.csdn.net/luckyxiaoqiang/article/details/7518888/ 版权所有&#xff0c;转载请注明出处&#xff0c;谢谢&#xff01;http://blog.csdn.net/walkinginthewind/article/details/7518888 树是一种比较重要的数据结构&#xff0c;尤其是二叉树。二…

百度UEditor开发案例(JSP)

本案例的开发环境&#xff1a;MyEclipsetomcatjdk 本案例的开发内容&#xff1a;用百度编辑器发布新闻&#xff08;UEditor的初始化开发部署&#xff09;编辑已发过的新闻&#xff08;UEditor的应用——编辑旧文章&#xff09;上传附件、图片等 由于百度编辑器强大的功能&a…

iOS中的动力学:Dynamics【1】

iOS7建议我们创建的界面具有物理特性&#xff0c;而不只是像素的集合&#xff0c;可以响应触摸、手势、屏幕方向改变等事件&#xff0c;让用户与界面之间有更深入的交互&#xff0c;而不是像iOS6那样在软件界面上模仿现实世界的纹理而已。或许你会认为创建感觉上真实的界面比创…

自动化运维工具Saltstack(一)

1、saltstack简介&#xff1a; 什么是saltstack&#xff1f; saltstack是基于python开发的一套C/S架构配置管理工具 使用SSL证书签方的方式进行认证管理 号称世界上最快的消息队列ZeroMQ使得SaltStack能快速在成千上万台机器上进行各种操作 采用RSA Key方式确认身份 传输采用AE…

【UIDynamic例子】挂起的方块

通过前面的动力学小Demo&#xff08;本文默认你已经看过这篇Blog&#xff1a;传送门&#xff09;&#xff0c;我们对UIKit中的UIDynamic已经有了初步的认识。现在我们写个更加有趣的Demo&#xff1a;模拟一个用弹性绳子挂起的小方块&#xff0c;用户可以将它拖动到屏幕任意位置…

IIS7 配置PHP服务器

安装PHP Manager&#xff1a; 1&#xff09;访问 http://phpmanager.codeplex.com/releases/view/69115 下载PHP Manager。其中&#xff0c;x86 为32位 Windows 系统使用&#xff0c;x64 为64位 Windows 系统使用&#xff0c;请根据使用的 Windows 系统情况下载 2&#xff09;下…

在文本框中提示用户输入内容格式的方法

希望达到的效果&#xff1a; 方法一&#xff1a;鼠标点击文本框时文字消失 <input id"login_name" type"text" οnblur"javascript:check_login_name();" οnfοcus"if(this.value支持英文及数字组合) this.value;this.style.color#000&…