`
ldl_xz
  • 浏览: 68896 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

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

 
阅读更多

效果图如下:

enter image description here

<!--more-->

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

<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

分享到:
评论

相关推荐

    jquery 日历控件 时分秒

    而如果想要一个轻量级且可高度定制的解决方案,那么基础的jQuery日历控件可能更合适,可以通过自定义代码来添加时分秒选择功能。对于视觉体验要求较高的项目,可以考虑结合使用日历控件和jQuery图片效果来提升界面...

    jQuery手机端HTML5带农历日期选择插件jQuery移动端日历插件swiper.js

    农历转换算法可能被嵌入到JavaScript代码中,以便将公历日期与农历日期对应起来,并在日历上同时显示。 iPhone的滚轮选择样式是一种模仿iOS设备日期选择器的交互方式,它提供了一种直观的日期选择体验。在插件中,...

    JQuery日历控件 .

    JQuery日历控件是一种广泛应用于网页开发中的交互式组件,它允许用户通过直观的日历界面选择日期。这种控件通常由JavaScript库JQuery提供支持,以增强网页的用户体验,尤其是涉及日期输入或日程安排的功能。在本篇...

    jquery日期控件(有下拉菜单选择年份)

    使用这个下拉菜单选择年份的jQuery日期控件,开发者可以轻松集成到自己的项目中,提高用户在填写日期时的效率和满意度。在实际应用中,只需引用相关的CSS和JS文件,并按照插件文档的指引配置选项,即可快速实现这个...

    jquery日期日历插件 单击文本框弹出日期选择控件

    标题中的"jquery日期日历插件 单击文本框弹出日期选择控件"就是这样一个功能,它允许用户在文本框中输入日期时,点击文本框会弹出一个日历,用户可以直观地从日历上选取日期。 描述中提到的"实用的日历效果,兼容性...

    jquery日历插件

    日历插件 一款非常好用的插件................................................................................................................................................................................

    jQuery制作简洁漂亮日期日历控件包含多选日期等

    本教程将详细讲解如何利用jQuery技术制作一款简洁且功能强大的日期日历控件,该控件支持多选日期,允许用户方便地选择开始和结束时间。这种控件的应用场景广泛,例如在预订系统、事件安排或数据分析中,可以极大地...

    日历控件(Jquery)

    在网页开发中,日历控件是...总的来说,jQuery日历控件通过便捷的API和丰富的插件,为开发者提供了构建高效、美观日期选择功能的解决方案。理解并熟练运用这些控件,能够显著提升用户体验,使网页应用更加互动和实用。

    jquery日期插件

    而“jquery日期插件”是jQuery生态中的一个重要组成部分,它为网页应用提供了丰富的日期处理功能,使得开发者能够更加方便地处理与日期相关的用户界面。 一、jQuery日期插件的基本概念 jQuery日期插件通常是独立于...

    jquery漂亮日期控件 jquery美化

    5. **js**:这个文件夹可能包含日期控件的主要JavaScript代码,包括jQuery插件实现,事件处理逻辑,以及可能的本地化支持。理解这些脚本可以帮助开发者进行高级定制和错误排查。 总的来说,"jQuery漂亮日期控件"和...

    jquery兼容所有浏览器双日历控件

    本资源提供了一个名为"jquery兼容所有浏览器双日历控件"的解决方案,它是一个高效、易用且跨浏览器的插件,特别适合那些需要用户输入两个日期范围的场景,如酒店预订、会议安排等。 该日历控件基于jQuery库,jQuery...

    仿携程网带价格的jQuery日期选择控件

    总结来说,"仿携程网带价格的jQuery日期选择控件"是一个结合了日期选择和价格展示的实用组件,它的实现涉及到了jQuery插件开发、CSS样式设计、Ajax异步通信等多个方面,对提升网站的用户体验有着重要作用。...

    jquery 日期时间控件

    这类控件通常提供交互式的日历视图和时间选择器,使得用户可以方便地输入或选择日期和时间,避免手动输入可能带来的错误。 在使用jQuery日期时间控件时,首先需要确保引入了jQuery库,因为这个控件是构建在jQuery...

    jQuery日期控件

    标题"jQuery日期控件"指的是使用jQuery和可能的插件(如jQuery UI、Bootstrap Datepicker等)来创建一个具有丰富功能和自定义样式的日期选择器。这些控件通常会提供比HTML5原生控件更广泛的支持和更丰富的用户体验。...

    jQuery日期日历选择器插件自定义多种日期选择

    在IT领域,前端开发中经常会使用到各种各样的插件来增强用户体验,特别是涉及到日期选择时,jQuery日期日历选择器插件就是一种常见的解决方案。本文将深入探讨jQuery日期日历选择器插件的自定义功能及其应用。 首先...

    携程网 时间控件 jquery控件 时间控件 php

    1. **jQuery插件开发**:这个时间控件可能是基于jQuery的一个自定义插件,允许开发者通过简单的调用来实现时间选择功能。jQuery插件通常包含初始化、事件处理和方法调用等部分,使得代码复用和扩展变得简单。 2. **...

    jquery的日历控件控件代码

    首先,jQuery日历控件是网页应用程序中常见的用户界面元素,它允许用户方便地选择日期,常用于表单输入或者时间相关的功能。这个控件的关键在于其跨浏览器兼容性,确保在不同的Web浏览器上能正常工作,包括IE和Fire...

    JQuery 时间控件、日期控件

    本主题将深入探讨jQuery中的时间控件和日期控件,这些组件在创建交互式用户界面时非常有用,特别是在处理表单输入或日历功能时。 1. **jQuery UI Datepicker** jQuery UI 提供了一个名为 "Datepicker" 的插件,它...

    jquery calendar.js日历选择控件带节日日历选择器

    总之,`jQuery Calendar.js`是一款实用的日历插件,适用于需要日期选择功能的网页应用。它的节日功能使得在处理日期相关事务时更加直观和有趣。通过简单的配置和调用,开发者可以轻松地将这款日历控件整合到自己的...

    JQuery日历控件

    **jQuery日历控件**是一种常见的前端开发工具,用于在网页上展示日期选择功能,它大大简化了在网页中添加交互式日历的过程。在给定的信息中,我们可以看到几个关键文件,它们共同构成了这个jQuery日历插件的组成部分...

Global site tag (gtag.js) - Google Analytics