文档章节

精确到秒的JQuery日期控件,jquery日历插件,jquery日期插件

rin9958
 rin9958
发布于 2016/03/21 21:02
字数 1565
阅读 554
收藏 8

效果图如下:

enter image description here

首先在页面中引用一下库:

<link type="text/css" href="css/jquery-ui-1.8.17.custom.css" rel="stylesheet" />
<link type="text/css" href="css/jquery-ui-timepicker-addon.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-zh-CN.js"></script>
  汉化包代码:

?
(function ($) {
    // 汉化 Datepicker
    $.datepicker.regional['zh-CN'] =
    {
        clearText: '清除', clearStatus: '清除已选日期',
        closeText: '关闭', closeStatus: '不改变当前选择',
        prevText: '<上月', prevStatus: '显示上月',
        nextText: '下月>', nextStatus: '显示下月',
        currentText: '今天', currentStatus: '显示本月',
        monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
        '七月', '八月', '九月', '十月', '十一月', '十二月'],
        monthNamesShort: ['一', '二', '三', '四', '五', '六',
        '七', '八', '九', '十', '十一', '十二'],
        monthStatus: '选择月份', yearStatus: '选择年份',
        weekHeader: '周', weekStatus: '年内周次',
        dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
        dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
        dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
        dayStatus: '设置 DD 为一周起始', dateStatus: '选择 m月 d日, DD',
        dateFormat: 'yy-mm-dd', firstDay: 1,
        initStatus: '请选择日期', isRTL: false
    };
    $.datepicker.setDefaults($.datepicker.regional['zh-CN']);

    //汉化 Timepicker
    $.timepicker.regional['zh-CN'] = {
        timeOnlyTitle: '选择时间',
        timeText: '时间',
        hourText: '小时',
        minuteText: '分钟',
        secondText: '秒钟',
        millisecText: '微秒',
        timezoneText: '时区',
        currentText: '现在时间',
        closeText: '关闭',
        timeFormat: 'hh:mm',
        amNames: ['AM', 'A'],
        pmNames: ['PM', 'P'],
        ampm: false
    };
    $.timepicker.setDefaults($.timepicker.regional['zh-CN']);
})(jQuery);

  注:汉化的逻辑就是,设置“zh-CN”标签的语言包内容,然后设置默认语言为“zh-CN”。

demo下载地址:精确到秒的JQuery日期控件.rar

参数说明: Localization Options

currentText
Default: "Now", A Localization Setting - Text for the Now button.
closeText
Default: "Done", A Localization Setting - Text for the Close button.
amNames
Default: ['AM', 'A'], A Localization Setting - Array of strings to try and parse against to determine AM.
pmNames
Default: ['PM', 'P'], A Localization Setting - Array of strings to try and parse against to determine PM.
timeFormat
Default: "HH:mm", A Localization Setting - String of format tokens to be replaced with the time. See Formatting.
timeSuffix
Default: "", A Localization Setting - String to place after the formatted time.
timeOnlyTitle
Default: "Choose Time", A Localization Setting - Title of the wigit when using only timepicker.
timeText
Default: "Time", A Localization Setting - Label used within timepicker for the formatted time.
hourText
Default: "Hour", A Localization Setting - Label used to identify the hour slider.
minuteText
Default: "Minute", A Localization Setting - Label used to identify the minute slider.
secondText
Default: "Second", A Localization Setting - Label used to identify the second slider.
millisecText
Default: "Millisecond", A Localization Setting - Label used to identify the millisecond slider.
microsecText
Default: "Microsecond", A Localization Setting - Label used to identify the microsecond slider.
timezoneText
Default: "Timezone", A Localization Setting - Label used to identify the timezone slider.
isRTL
Default: false, A Localization Setting - Right to Left support.
Alt Field Options

altFieldTimeOnly
Default: true - When altField is used from datepicker altField will only receive the formatted time and the original field only receives date.
altSeparator
Default: (separator option) - String placed between formatted date and formatted time in the altField.
altTimeSuffix
Default: (timeSuffix option) - String always placed after the formatted time in the altField.
altTimeFormat
Default: (timeFormat option) - The time format to use with the altField.
Timezone Options

timezoneList
Default: [generated timezones] - An array of timezones used to populate the timezone select. Can be an array of values or an array of objects: { label: "EDT", value: -240 }. The value should be the offset number in minutes. So "-0400" which is the format "-hhmm", would equate to -240 minutes.
Time Field Options

controlType
Default: 'slider' - Whether to use 'slider' or 'select'. If 'slider' is unavailable through jQueryUI, 'select' will be used. For advanced usage you may pass an object which implements "create", "options", "value" methods to use controls other than sliders or selects. See the _controls property in the source code for more details.
{
    create: function(tp_inst, obj, unit, val, min, max, step){    
        // generate whatever controls you want here, just return obj
    },
    options: function(tp_inst, obj, unit, opts, val){
        // if val==undefined return the value, else return obj
    },
    value: function(tp_inst, obj, unit, val){
        // if val==undefined return the value, else return obj
    }
}
showHour
Default: null - Whether to show the hour control. The default of null will use detection from timeFormat.
showMinute
Default: null - Whether to show the minute control. The default of null will use detection from timeFormat.
showSecond
Default: null - Whether to show the second control. The default of null will use detection from timeFormat.
showMillisec
Default: null - Whether to show the millisecond control. The default of null will use detection from timeFormat.
showMicrosec
Default: null - Whether to show the microsecond control. The default of null will use detection from timeFormat.
showTimezone
Default: null - Whether to show the timezone select.
showTime
Default: true - Whether to show the time selected within the datetimepicker.
stepHour
Default: 1 - Hours per step the slider makes.
stepMinute
Default: 1 - Minutes per step the slider makes.
stepSecond
Default: 1 - Seconds per step the slider makes.
stepMillisec
Default: 1 - Milliseconds per step the slider makes.
stepMicrosec
Default: 1 - Microseconds per step the slider makes.
hour
Default: 0 - Initial hour set.
minute
Default: 0 - Initial minute set.
second
Default: 0 - Initial second set.
millisec
Default: 0 - Initial millisecond set.
microsec
Default: 0 - Initial microsecond set. Note: Javascript's native Date object does not natively support microseconds. Timepicker adds ability to simply Date.setMicroseconds(m) and Date.getMicroseconds(). Date comparisons will not acknowledge microseconds. Use this only for display purposes.
timezone
Default: null - Initial timezone set. This is the offset in minutes. If null the browser's local timezone will be used. If you're timezone is "-0400" you would use -240. For backwards compatibility you may pass "-0400", however the timezone is stored in minutes and more reliable.
hourMin
Default: 0 - The minimum hour allowed for all dates.
minuteMin
Default: 0 - The minimum minute allowed for all dates.
secondMin
Default: 0 - The minimum second allowed for all dates.
millisecMin
Default: 0 - The minimum millisecond allowed for all dates.
microsecMin
Default: 0 - The minimum microsecond allowed for all dates.
hourMax
Default: 23 - The maximum hour allowed for all dates.
minuteMax
Default: 59 - The maximum minute allowed for all dates.
secondMax
Default: 59 - The maximum second allowed for all dates.
millisecMax
Default: 999 - The maximum millisecond allowed for all dates.
microsecMax
Default: 999 - The maximum microsecond allowed for all dates.
hourGrid
Default: 0 - When greater than 0 a label grid will be generated under the slider. This number represents the units (in hours) between labels.
minuteGrid
Default: 0 - When greater than 0 a label grid will be generated under the slider. This number represents the units (in minutes) between labels.
secondGrid
Default: 0 - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in seconds) between labels.
millisecGrid
Default: 0 - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in milliseconds) between labels.
microsecGrid
Default: 0 - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in microseconds) between labels.
Other Options

showButtonPanel
Default: true - Whether to show the button panel at the bottom. This is generally needed.
timeOnly
Default: false - Hide the datepicker and only provide a time interface.
onSelect
Default: null - Function to be called when a date is chosen or time has changed (parameters: datetimeText, datepickerInstance).
alwaysSetTime
Default: true - Always have a time set internally, even before user has chosen one.
separator
Default: " " - When formatting the time this string is placed between the formatted date and formatted time.
pickerTimeFormat
Default: (timeFormat option) - How to format the time displayed within the timepicker.
pickerTimeSuffix
Default: (timeSuffix option) - String to place after the formatted time within the timepicker.
showTimepicker
Default: true - Whether to show the timepicker within the datepicker.
addSliderAccess
Default: false - Adds the sliderAccess plugin to sliders within timepicker
sliderAccessArgs
Default: null - Object to pass to sliderAccess when used.
defaultValue
Default: null - String of the default time value placed in the input on focus when the input is empty.
minDateTime
Default: null - Date object of the minimum datetime allowed. Also available as minDate.
maxDateTime
Default: null - Date object of the maximum datetime allowed. Also Available as maxDate.
parse
Default: 'strict' - How to parse the time string. Two methods are provided: 'strict' which must match the timeFormat exactly, and 'loose' which uses javascript's new Date(timeString) to guess the time. You may also pass in a function(timeFormat, timeString, options) to handle the parsing yourself, returning a simple object:

更多参数设置请参考:http://trentrichardson.com/examples/timepicker/


转载自:http://www.9958.pw/post/jquery_timepicker

© 著作权归作者所有

共有 人打赏支持
rin9958
粉丝 9
博文 113
码字总数 54109
作品 0
程序员
私信 提问
给开发者准备的 10 款最好的 jQuery 日历插件

这篇文章介绍的是 10 款最棒而且又很有用的 jQuery 日历插件,允许开发者们把这些漂亮的日历插件结合到自己的网站中。这些日历插件易用性都很强,轻轻松松的就可以把漂亮的日历插件装饰到你的...

oschina
2014/01/27
50.9K
10
10 新鲜的 jQuery 插件(2012年1月)

1. jQuery UI Bootstrap 一个基于 Twitter Bootstrap 的 jQuery UI 主题 2. jqGrid 这是非常棒的jQuery 表格插件,在线演示:here. 3. Cloud Zoom Cloud Zoom 是一个小型的图像放大镜插件,放...

红薯
2012/02/01
4.8K
6
25 个最棒的 jQuery 日期时间选择器

jQuery 日期时间选择插件允许您将datepicker功能添加到您的网站,提供更好的用户体验。本文向你推荐 25 个超棒的 jQuery 日期时间选择插件。 走起! 1. jQuery Timer Plugin 2. Timepicki 3....

oschina
2015/01/03
18.4K
12
提供给开发者的 20 款最棒的 jQuery Bootstrap 插件

Twitter Bootstrap 是最流行的前端框架之一,作为开发者用作建立有效和有用的Web应用的手段,它可被看作是网络发展的中坚力量。它功能很丰富:使用12列响应网格,众多组件,JavaScript插件,...

oschina
2014/06/19
42.3K
41
20个jQuery插件,帮你打造完美网页表单

网页表单主要是用来从用户那里收集一些必要的信息,是网页设计中不可或缺的一环。一个设计良好的表单能更有效的获取用户信息,也会给用户带来更好地使用体 验。基于这一点,很多设计师开始使...

鉴客
2012/03/31
4.9K
13

没有更多内容

加载失败,请刷新页面

加载更多

一枚戒指,一场仪式,这件事阿里巴巴坚持了15年

为入职满五年的员工举行盛大仪式,为他们每个人戴上私人订制的戒指,是阿里巴巴坚持了15年“五年陈”的传统。1月22日,阿里集团为最新一季的“五年陈”们举行了授戒仪式。 2018五年陈小档案 ...

阿里云官方博客
24分钟前
0
0
前后端常见的几种鉴权方式

什么是鉴权 鉴权是指验证用户访问系统的权力 常用的鉴权有四种: HTTP Basic Authentication session-cookie Token 验证 OAuth(开放授权) HTTP Basic Authentication 这种授权方式是浏览器遵...

小草先森
26分钟前
2
0
Spring Cloud 微服务搭建注意的几个点

参考教程 https://www.fangzhipeng.com/springcloud/2018/08/30/sc-f1-eureka/ 1)@EnableEurekaServer 引入标红,引入失败 ; @EnableEurekaClient 亦同 其中会出现 @EnableEurekaServer 引入......

阿白
32分钟前
2
0
PyCharm入门教程——在编辑器中打开和重新打开文件

PyCharm最新版本下载 JetBrains PyCharm是一种Python IDE,其带有一整套可以帮助用户在使用Python语言开发时提高其效率的工具。此外,该IDE提供了一些高级功能,以用于Django框架下的专业Web...

电池盒
35分钟前
1
0
数据生产与收集

数据 对于移动端的app来说, 分析的数据大致上都可以分为俩种, 一种是在线数据,一种是离线数据。 在线数据, 即app后端服务所产生的日志数据,例如服务接口的性能数据, 服务接口的调用及其...

hblt-j
42分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部