博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
精确到秒的JQuery日期控件,jquery日历插件,jquery日期插件
阅读量:6842 次
发布时间:2019-06-26

本文共 9478 字,大约阅读时间需要 31 分钟。

hot3.png

效果图如下:

enter image description here

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

  汉化包代码:?(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下载地址:

参数说明: Localization Options

currentTextDefault: "Now", A Localization Setting - Text for the Now button.closeTextDefault: "Done", A Localization Setting - Text for the Close button.amNamesDefault: ['AM', 'A'], A Localization Setting - Array of strings to try and parse against to determine AM.pmNamesDefault: ['PM', 'P'], A Localization Setting - Array of strings to try and parse against to determine PM.timeFormatDefault: "HH:mm", A Localization Setting - String of format tokens to be replaced with the time. See Formatting.timeSuffixDefault: "", A Localization Setting - String to place after the formatted time.timeOnlyTitleDefault: "Choose Time", A Localization Setting - Title of the wigit when using only timepicker.timeTextDefault: "Time", A Localization Setting - Label used within timepicker for the formatted time.hourTextDefault: "Hour", A Localization Setting - Label used to identify the hour slider.minuteTextDefault: "Minute", A Localization Setting - Label used to identify the minute slider.secondTextDefault: "Second", A Localization Setting - Label used to identify the second slider.millisecTextDefault: "Millisecond", A Localization Setting - Label used to identify the millisecond slider.microsecTextDefault: "Microsecond", A Localization Setting - Label used to identify the microsecond slider.timezoneTextDefault: "Timezone", A Localization Setting - Label used to identify the timezone slider.isRTLDefault: false, A Localization Setting - Right to Left support.Alt Field OptionsaltFieldTimeOnlyDefault: true - When altField is used from datepicker altField will only receive the formatted time and the original field only receives date.altSeparatorDefault: (separator option) - String placed between formatted date and formatted time in the altField.altTimeSuffixDefault: (timeSuffix option) - String always placed after the formatted time in the altField.altTimeFormatDefault: (timeFormat option) - The time format to use with the altField.Timezone OptionstimezoneListDefault: [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 OptionscontrolTypeDefault: '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    }}showHourDefault: null - Whether to show the hour control. The default of null will use detection from timeFormat.showMinuteDefault: null - Whether to show the minute control. The default of null will use detection from timeFormat.showSecondDefault: null - Whether to show the second control. The default of null will use detection from timeFormat.showMillisecDefault: null - Whether to show the millisecond control. The default of null will use detection from timeFormat.showMicrosecDefault: null - Whether to show the microsecond control. The default of null will use detection from timeFormat.showTimezoneDefault: null - Whether to show the timezone select.showTimeDefault: true - Whether to show the time selected within the datetimepicker.stepHourDefault: 1 - Hours per step the slider makes.stepMinuteDefault: 1 - Minutes per step the slider makes.stepSecondDefault: 1 - Seconds per step the slider makes.stepMillisecDefault: 1 - Milliseconds per step the slider makes.stepMicrosecDefault: 1 - Microseconds per step the slider makes.hourDefault: 0 - Initial hour set.minuteDefault: 0 - Initial minute set.secondDefault: 0 - Initial second set.millisecDefault: 0 - Initial millisecond set.microsecDefault: 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.timezoneDefault: 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.hourMinDefault: 0 - The minimum hour allowed for all dates.minuteMinDefault: 0 - The minimum minute allowed for all dates.secondMinDefault: 0 - The minimum second allowed for all dates.millisecMinDefault: 0 - The minimum millisecond allowed for all dates.microsecMinDefault: 0 - The minimum microsecond allowed for all dates.hourMaxDefault: 23 - The maximum hour allowed for all dates.minuteMaxDefault: 59 - The maximum minute allowed for all dates.secondMaxDefault: 59 - The maximum second allowed for all dates.millisecMaxDefault: 999 - The maximum millisecond allowed for all dates.microsecMaxDefault: 999 - The maximum microsecond allowed for all dates.hourGridDefault: 0 - When greater than 0 a label grid will be generated under the slider. This number represents the units (in hours) between labels.minuteGridDefault: 0 - When greater than 0 a label grid will be generated under the slider. This number represents the units (in minutes) between labels.secondGridDefault: 0 - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in seconds) between labels.millisecGridDefault: 0 - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in milliseconds) between labels.microsecGridDefault: 0 - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in microseconds) between labels.Other OptionsshowButtonPanelDefault: true - Whether to show the button panel at the bottom. This is generally needed.timeOnlyDefault: false - Hide the datepicker and only provide a time interface.onSelectDefault: null - Function to be called when a date is chosen or time has changed (parameters: datetimeText, datepickerInstance).alwaysSetTimeDefault: true - Always have a time set internally, even before user has chosen one.separatorDefault: " " - When formatting the time this string is placed between the formatted date and formatted time.pickerTimeFormatDefault: (timeFormat option) - How to format the time displayed within the timepicker.pickerTimeSuffixDefault: (timeSuffix option) - String to place after the formatted time within the timepicker.showTimepickerDefault: true - Whether to show the timepicker within the datepicker.addSliderAccessDefault: false - Adds the sliderAccess plugin to sliders within timepickersliderAccessArgsDefault: null - Object to pass to sliderAccess when used.defaultValueDefault: null - String of the default time value placed in the input on focus when the input is empty.minDateTimeDefault: null - Date object of the minimum datetime allowed. Also available as minDate.maxDateTimeDefault: null - Date object of the maximum datetime allowed. Also Available as maxDate.parseDefault: '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:

更多参数设置请参考:

转载自:

转载于:https://my.oschina.net/u/1179286/blog/644764

你可能感兴趣的文章
React Native入门遇到的一些问题
查看>>
jquery.timepicker.js - 最常用的日期JS控件
查看>>
C语言中你可能不熟悉的头文件(stdlib.h)
查看>>
LeetCode(258):Add Digits
查看>>
mysql-multi source replication 配置
查看>>
由传输过程中需要面对的问题探讨WCF中的“可靠性”
查看>>
iOS的GCD精要
查看>>
取得ld默认的ldscript配置
查看>>
精简版—愤慨的小鸟
查看>>
让你提前认识软件开发(36):怎样扩展数据表字段?
查看>>
静态代理模式
查看>>
jsp导出身份证到excel时候格式不正确
查看>>
学习笔记
查看>>
病毒小记
查看>>
切蛋糕
查看>>
基于mysql的数据管理
查看>>
十进制转化为2/8/16
查看>>
iOS开发经验
查看>>
作业(十)
查看>>
内存拷贝
查看>>