文档章节

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

rin9958
 rin9958
发布于 2016/03/21 21:02
字数 1565
阅读 548
收藏 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
程序员
私信 提问
jquery常用的插件1000收集

花N长时间积累的Jquery插件,希望大家喜欢。大家还有什么新的插件,请留言,我们一并收录。 感谢大家的支持。 1.accordion类 基于jQuery开发,非常简单的水平方向折叠控件。 Horizontal acc...

Alic
2011/03/07
0
6
【jQuery-UI】jQuery Timepicker Addon--时间选择插件

jQuery UI官方的日期控件Datepicker中没有提供时间(时分秒)的选择,还好网上有人写了针对jQuery UI Datepciker的插件 - jQuery Timepicker Addon,它依赖于jQuery UI中的datepicker和slide...

5W1H-
2013/01/10
0
4
2011年12月最新JQuery插件汇总

jQuery的工具提示插件 Tipped jQuery表格插件 colResizable jQuery虚拟键盘插件 jQuery keyboard Minimit Gallery 用于显示相册、幻灯片、卷帘等效果 jQuery 幻灯效果显示插件 Diapo jQuery...

晨曦之光
2012/02/24
0
0
分享10个帮助你实现超酷特效的jQuery插件

日期:2012-4-4 来源:GBin1.com 今天我们这篇文章中将推荐给大家10个超酷的jQuery插件帮助大家实现超酷的jQuery特效,绝对超过其它的普通jQuery插件。希望大家喜欢! 1. jQuery Lens Flare...

gbin1
2012/04/05
0
0
[备忘]jQuery UI Datepicker的时间选择插件 - jQuery Timepi...

太遗憾了,jQuery UI官方的日期控件Datepicker中居然没有提供时间(时分秒)的选择,还好网上有人写了针对jQuery UI Datepciker的插件——jQuery Timepicker Addon,它依赖于jQuery UI中的d...

leeoo
2011/12/27
0
2

没有更多内容

加载失败,请刷新页面

加载更多

安卓的切图规范

Android UI 切图命名规范、标注规范及单位描述 很多UI设计师做APP切图都会有两套,一套是Android的,一套是IOS的。IOS我这边暂不作讲解,因为我本人也不是开发IOS。这里整理一下我在Android...

mo311
30分钟前
2
0
深度剖析阿里巴巴对Flink的优化与改进

摘要: 作者 | 阿里巴巴实时计算团队 导读:随着人工智能时代的降临,数据量的爆发,阿里巴巴的商品数据处理就经常需要面对增量和全量两套不同的业务流程问题,所以阿里巴巴就在想:能不能有...

阿里云官方博客
31分钟前
2
0
Dubbo基础介绍

Dubbo是一个常用的分布式服务框架, 它致力于提供高性能、透明化的RPC远程服务方案。 学习Dubbo有助于提高企业级应用的开发效率,以及可通过简单的配置就可以实现负载均衡,提高服务的效率。...

Java搬砖工程师
42分钟前
4
0
VBS 自动登陆

1.关于网页元素属性 IE浏览器打开网页时,有很多元素,比如说一个文本框,一个按键等。每个元素都会有对应的“name”、“ID”,“style”,“class”等属性。 其中的“ID”和“name”属性是我...

宝贝女儿
46分钟前
1
0
GO 文件相关操作

package mainimport("fmt""os""bufio""io""io/ioutil")type ChartCount struct{Chct intSpacect intNumberct intOtherct int}func main() {file,err := os.Open......

汤汤圆圆
48分钟前
3
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部