http://www.oschina.net/p/timedifference
/** Created by postbird on 2016/4/1. ...*/
/**
* @postbird
* 1、本插件采用js编写,可直接将函数复制到个人js文件,减少get请求数
* 2、author:powered by postbird
* 3、email: ptbird@yeah.net
* 4、site:http://www.ptbird.cn
* 5、license : MIT
* */
/**
* 函数使用说明:
* 1、直接调用函数 TimeDifference()
* 返回说明: 返回距离当前的时间差
* */
function timeDifference(tmpTime) {
var mm=1000;//1000毫秒 代表1秒
var minute = mm * 60;
var hour = minute * 60;
var day = hour * 24;
var month = day * 30;
var ansTimeDifference=0;//记录时间差
var tmpTimeStamp = tmpTime ? Date.parse(tmpTime.replace(/-/gi, "/")) : new Date().getTime();//将 yyyy-mm-dd H:m:s 进行正则匹配
var nowTime = new Date().getTime();//获取当前时间戳
var tmpTimeDifference = nowTime - tmpTimeStamp;//计算当前与需要计算的时间的时间戳的差值
if (tmpTimeDifference < 0) { //时间超出,不能计算
alert("开始日期大于结束日期,计算失败!");
return 0;
}
/**
* 通过最开始强调的各个时间段用毫秒表示的数值,进行时间上的取整,为0的话,则没有到达
* */
var DifferebceMonth = tmpTimeDifference / month; //进行月份取整
var DifferebceWeek = tmpTimeDifference / (7 * day);//进行周取整
var DifferebceDay = tmpTimeDifference / day;//进行天取整
var DifferebceHour = tmpTimeDifference / hour;//进行小时取整
var DifferebceMinute = tmpTimeDifference / minute;//进行分钟取整
if (DifferebceMonth >= 1) {
return tmpTime; //大于一个月 直接返回时间
} else if (DifferebceWeek >= 1) {
ansTimeDifference= parseInt(DifferebceWeek) + "个星期前";
} else if (DifferebceDay >= 1) {
ansTimeDifference = parseInt(DifferebceDay) + "天前";
} else if (DifferebceHour >= 1) {
ansTimeDifference = parseInt(DifferebceHour) + "个小时前";
} else if (DifferebceMinute >= 1) {
ansTimeDifference = parseInt(DifferebceMinute) + "分钟前";
} else {
ansTimeDifference = "刚刚";
}
return ansTimeDifference;
}
分享到:
相关推荐
differentiation_difference.pdf
magazins make a difference.ppt
interpolation_divided_difference.pdf
背景提取代码,利用帧差分发提取视频背景,测试视频以avi格式为佳
Euler_difference.txt+前向欧拉法+后向欧拉法+中心差分法+matlab程序
Node.js is a server-side JavaScript platform using an event-driven, non-blocking I/O model allowing users to build fast and scalable data-intensive applications running in real time. This book gives ...
A computer's architecture is its abstract model and is the programmer's view in terms of instructions, addressing modes and registers. A computer's organization expresses the realization of the ...
严蔚敏数据结构与算法▲课本算法实现
严蔚敏数据结构与算法▲课本算法实现
Difference Be...Pronunciation_马生虎.caj
通过读取视频中连续几帧图像,利用差分法获得目标图像
一维对流方程的后差分格式(v大于零时即为迎风格式)计算实例,由matlab编写实现,有助于初学者加深理解
对DES算法S-box差分分布表的C语言编程实现,并打印输出。代码以S1为例,使用时只需替换为8个sbox中的任意一个即可。
基于幅度的和差测角程序,程序完整,测角是入门目标跟踪必不可少的阶段。
采用相关法在TMS320F28035上实现计算两个信号相位差
有需要货源的私信
网上找了很多代码,都没有一个真正可用的,整理了很多代码,最后仅仅依靠js就实现了,不需要任何插件
3.1 Trend- versus Difference-Stationary Series . . . . . . . . . . . . . . . . . . 53 3.2 Unit RootProcesses ..................................... 55 3.3 Long-MemoryProcesses.............................
安装将此行添加到您的应用程序的Gemfile中: gem 'time_difference' 然后执行: $ bundle install用法适用于时间,日期时间和日期 # Timestart_time = Time . new ( 2013 , 1 )end_time = Time . new ( 2014 , 1 )...
Finite Difference Method.ipynb