一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

jquery日期时间My97DatePicker选择控件函数使用例子

时间:2014-04-15 编辑:简简单单 来源:一聚教程网

1、推荐日期选择控件:My97DatePicker
My97DatePicker是一个非常好用的日期/时间选择控件,支持多种日期时间类型等;

IT分享My97DatePicker是一个非常好用的日期/时间选择控件

支持的浏览器

IE 6.0+ , Firefox 2.0+ , Chrome, Opera 9.5+ , Safari 3.0+

注意:IE 8/9/10/11是完美支持的

功能如下:

常规功能

支持多种调用模式

下拉,输入,导航选择日期

支持周显示

只读开关,高亮周末功能

操作按钮自定义

自动选择显示位置

自定义弹出位置

自定义星期的第一天new

特色功能

平面显示

支持多种容器

起始日期功能

自定义格式new

双月日历功能new

自动纠错功能

跨无限级框架显示

民国年日历和其他特殊日历

编辑功能

为编程带来方便

其他属性

多语言和自定义皮肤

多语言支持

自定义和动态切换皮肤

日期范围限制

静态限制

动态限制

脚本自定义限制

无效天

无效日期

有效日期

特殊天和特殊日期new

自定义事件

自定义事件

onpicking和onpicked事件

onclearing和oncleared事件

changing和changed事件

2、js时间处理类库

js中是没有DateDiff、DateAdd函数的。因此需要引用一个插件:Datejs

项目地址:http://www.datejs.com/download/

中文版:https://code.google.com/p/datejs/source/browse/trunk/build/date-zh-cn.js?spec=svn185&r=185

主要功能:

 代码如下 复制代码


Date.today()                    // Returns today's date, with time set to 00:00 (start of day).
Date.today().next().friday()    // Returns the date of the next Friday.
Date.today().last().monday()    // Returns the date of the previous Monday.
new Date().next().march()       // Returns the date of the next March.
new Date().last().week()        // Returns the date one week ago.
Date.today().is().friday()      // Returns true|false if the day-of-week matches.
Date.today().is().fri()         // Abbreviated day names.
Date.today().is().november()    // Month names.
Date.today().is().nov()         // Abbreviated month names.
Date.today().is().weekday()     // Is today a weekday?
Date.today().addDays(1)         // Add one day (+1).
Date.today().addMonths(-3)      // Subtract three months (-3).
Date.today().add(1).day()    
  // Add one (+1) day. Supports all date parts
   (year, month, day, hour, minute, second, millisecond, and weeks)
Date.today().add(-3).months()   // Subtract three (-3) months.
(1).day().fromNow()             // One (1) day from now.
(3).months().ago()              // Three (3) months ago.
var n = 6;
n.months().fromNow()            // Six (6) months from now.
Date.monday()                   // Returns Monday of the current week.
Date.mon()                      // Abbreviated version of Date.monday()
Date.march()                    // Returns March 1st of this year.
Date.mar()                      // Abbreviated version of Date.march()
Date.today().first().thursday() // Returns the first Thursday of the current month.
Date.today().second().thursday()// Returns the second Thursday of the current month.
Date.march().third().thursday() // Returns the third Thursday in March of the current year.
Date.october().fourth().sunday()// Returns the fourth Sunday in October.
Date.today().fifth().sunday()  
// Returns the fifth Sunday in the current month, or throws a RangeError
exception if there are not 5 Sundays in the current month.
Date.october().final().sunday() // Returns the final Sunday in October.
Date.january().first().monday() // Returns the first Monday of the current year.
Date.december().final().friday()// Returns the last Friday of the current year.
Date.today().at("6:15pm");      // Returns todays date at 6:15pm.
var time = {hour:18, minute:15};
Date.today().at(time);          // Set time with a config object.
var birthDayParty = {month: 1, day: 20, hour: 20, minute: 30};
Date.today().set(birthDayParty);// Set date and time with a config object.


3、js延迟执行和定时执行

setTimeout()和setInterval()经常被用来处理延时和定时任务。setTimeout() 方法用于在指定的毫秒数后调用函数或计算表达式,而setInterval()则可以在每隔指定的毫秒数循环调用函数或表达式,直到clearInterval把它清除。

例子:

 代码如下 复制代码

setTimeout('document.write("Delayed alert!");', 2000);
定时执行:

var timerr=setInterval(function() {
       
  var date = new Date();
  document.write(date.getMinutes() + ':'
  + date.getSeconds() + ':' + date.getMilliseconds() + '
');   
             
        }, 1000);
//达到某个条件就取消定时执行
   clearInterval(timerr);

传递参数:

 

 代码如下 复制代码

function foo()
{
    var param = 100;
    window.setInterval(function()
    {
        intervalRun(param);
    }, 888);
}
function interalRun(times)
{
    // todo: depend on times parameter
}

 

热门栏目