当前位置:首页 > 生活百科

jq获取当前日期前一个月(javascript获取当前系统时间)

栏目:生活百科日期:2025-06-03浏览:0

默认功能

日期选择器(Datepicker)绑定到一个标准的表单 input 字段上。把焦点移到 input 上(点击或者使用 tab 键),在一个小的覆盖层上打开一个交互日历。选择一个日期,点击页面上的任意地方(输入框即失去焦点),或者点击 Esc 键来关闭。如果选择了一个日期,则反馈显示为 input 的值。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 默认功能&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker(); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker"&>&</p&> &</body&> &</html&>

查看演示

动画

当打开或关闭 datepicker 时使用不同的动画。从下拉框中选择一个动画,然后在输入框中点击来查看它的效果。您可以使用三个标准动画中任意一个,或者使用 UI 特效中的任意一个。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 动画&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker(); $( "#anim" ).change(function() { $( "#datepicker" ).datepicker( "option", "showAnim", $( this ).val() ); }); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker" size="30"&>&</p&> &<p&>动画:&<br&> &<select id="anim"&> &<option value="show"&>Show (默认)&</option&> &<option value="slideDown"&>滑下&</option&> &<option value="fadeIn"&>淡入&</option&> &<option value="blind"&>Blind (UI 百叶窗特效)&</option&> &<option value="bounce"&>Bounce (UI 反弹特效)&</option&> &<option value="clip"&>Clip (UI 剪辑特效)&</option&> &<option value="drop"&>Drop (UI 降落特效)&</option&> &<option value="fold"&>Fold (UI 折叠特效)&</option&> &<option value="slide"&>Slide (UI 滑动特效)&</option&> &<option value=""&>无&</option&> &</select&> &</p&> &</body&> &</html&>

查看演示

其他月份的日期

datepicker 可以显示其他月份的日期,这些日期也可以设置成可选择的。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 其他月份的日期&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker({ showOtherMonths: true, selectOtherMonths: true }); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker"&>&</p&> &</body&> &</html&>

查看演示

显示按钮栏

通过布尔值的 showButtonPanel 选项为选择当天日期显示一个&”Today&”按钮,为关闭日历显示一个&”Done&”按钮。默认情况下,当按钮栏显示时会启用每个按钮,但是按钮可通过其他的选项进行关闭。按钮文本可自定义。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 显示按钮栏&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker({ showButtonPanel: true }); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker"&>&</p&> &</body&> &</html&>

查看演示

内联显示

datepicker 是嵌套在页面中显示,而不是显示在一个覆盖层中。只需要简单地在 p 上调用 .datepicker() 即可,而不是在 input 上调用。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 内联显示&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker(); }); &</script&> &</head&> &<body&> 日期:&<p id="datepicker"&>&</p&> &</body&> &</html&>

查看演示

显示月份 && 年份菜单

显示月份和年份的下拉框,而不是显示静态的月份/年份标题,这样便于在大范围的时间跨度上导航。添加布尔值 changeMonthchangeYear 选项即可。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 显示月份 &&amp; 年份菜单&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker({ changeMonth: true, changeYear: true }); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker"&>&</p&> &</body&> &</html&>

查看演示

显示多个月份

设置 numberOfMonths 选项为一个整数 2,或者大于 2 的整数,来在一个 datepicker 中显示多个月份。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 显示多个月份&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker({ numberOfMonths: 3, showButtonPanel: true }); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker"&>&</p&> &</body&> &</html&>

查看演示

格式化日期

以各种方式显示日期反馈。从下拉框中选择一种日期格式,然后在输入框中点击并选择一个日期,查看所选格式的日期显示。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 格式化日期&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker(); $( "#format" ).change(function() { $( "#datepicker" ).datepicker( "option", "dateFormat", $( this ).val() ); }); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker" size="30"&>&</p&> &<p&>格式选项:&<br&> &<select id="format"&> &<option value="mm/dd/yy"&>Default - mm/dd/yy&</option&> &<option value="yy-mm-dd"&>ISO 8601 - yy-mm-dd&</option&> &<option value="d M, y"&>Short - d M, y&</option&> &<option value="d MM, y"&>Medium - d MM, y&</option&> &<option value="DD, d MM, yy"&>Full - DD, d MM, yy&</option&> &<option value="&&apos;day&&apos; d &&apos;of&&apos; MM &&apos;in the year&&apos; yy"&>With text - 'day' d 'of' MM 'in the year' yy&</option&> &</select&> &</p&> &</body&> &</html&>

查看演示

图标触发器

点击输入框旁边的图标来显示 datepicker。设置 datepicker 在获得焦点时打开(默认行为),或者在点击图标时打开,或者在获得焦点/点击图标时打开。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 图标触发器&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker({ showOn: "button", buttonImage: "images/calendar.gif", buttonImageOnly: true }); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker"&>&</p&> &</body&> &</html&>

查看演示

本地化日历

本地化 datepicker 日历语言和格式(默认为 English / Western 格式)。datepicker 包含对从右到左读取的语言的内建支持,比如 Arabic 和 Hebrew。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 本地化日历&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<script src="http://jqueryui.com/resources/demos/datepicker/jquery.ui.datepicker-ar.js"&>&</script&> &<script src="http://jqueryui.com/resources/demos/datepicker/jquery.ui.datepicker-fr.js"&>&</script&> &<script src="http://jqueryui.com/resources/demos/datepicker/jquery.ui.datepicker-he.js"&>&</script&> &<script src="http://jqueryui.com/resources/demos/datepicker/jquery.ui.datepicker-zh-TW.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker( $.datepicker.regional[ "fr" ] ); $( "#locale" ).change(function() { $( "#datepicker" ).datepicker( "option", $.datepicker.regional[ $( this ).val() ] ); }); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker"&>&&nbsp; &<select id="locale"&> &<option value="ar"&>Arabic (&&#8235;(&&#1575;&&#1604;&&#1593;&&#1585;&&#1576;&&#1610;&&#1577;&</option&> &<option value="zh-TW"&>Chinese Traditional (&&#32321;&&#39636;&&#20013;&&#25991;)&</option&> &<option value=""&>English&</option&> &<option value="fr" selected="selected"&>French (Fran&&ccedil;ais)&</option&> &<option value="he"&>Hebrew (&&#8235;(&&#1506;&&#1489;&&#1512;&&#1497;&&#1514;&</option&> &</select&>&</p&> &</body&> &</html&>

填充另一个输入框

使用 altFieldaltFormat 选项,无论何时选择日期,会在另一个输入框中填充带有一定格式的日期。这个功能通过对电脑友好性的日期进一步加工后,向用户呈现一个用户友好性的日期。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 填充另一个输入框&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker({ altField: "#alternate", altFormat: "DD, d MM, yy" }); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker"&>&&nbsp;&<input type="text" id="alternate" size="30"&>&</p&> &</body&> &</html&>

限制日期范围

通过 minDatemaxDate 选项限制可选择的日期范围。设置起止日期为实际的日期(new Date(2009, 1 &– 1, 26)),或者为与今天的一个数值偏移(-20),或者为一个周期和单位的字符串(&’+1M +10D&’)。如果设置为字符串,使用 &‘D&’ 表示天,使用 &‘W&’ 表示周,使用 &‘M&’ 表示月,使用 &‘Y&’ 表示年。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 限制日期范围&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker({ minDate: -20, maxDate: "+1M +10D" }); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker"&>&</p&> &</body&> &</html&>

选择一个日期范围

选择要搜索的日期范围。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 选择一个日期范围&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#from" ).datepicker({ defaultDate: "+1w", changeMonth: true, numberOfMonths: 3, onClose: function( selectedDate ) { $( "#to" ).datepicker( "option", "minDate", selectedDate ); } }); $( "#to" ).datepicker({ defaultDate: "+1w", changeMonth: true, numberOfMonths: 3, onClose: function( selectedDate ) { $( "#from" ).datepicker( "option", "maxDate", selectedDate ); } }); }); &</script&> &</head&> &<body&> &<label for="from"&>从&</label&> &<input type="text" id="from" name="from"&> &<label for="to"&>到&</label&> &<input type="text" id="to" name="to"&> &</body&> &</html&>

显示一年中的第几周

datepicker 可以显示一年中的第几周。默认的计算是按照 ISO 8601 定义:每周从星期一开始,每年的第一周包含该年的第一个星期四。这就意味着一年中的一些天可能是属于另一年中的周。

&<!doctype html&> &<html&> &<head&> &<meta charset="utf-8"&> &<title&>jQuery UI 日期选择器(Datepicker) - 显示一年中的第几周&</title&> &<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&> &<script src="//code.jquery.com/jquery-1.9.1.js"&>&</script&> &<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&>&</script&> &<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"&> &<script&> $(function() { $( "#datepicker" ).datepicker({ showWeek: true, firstDay: 1 }); }); &</script&> &</head&> &<body&> &<p&>日期:&<input type="text" id="datepicker"&>&</p&> &</body&> &</html&>

“jq获取当前日期前一个月(javascript获取当前系统时间)” 的相关文章

二寸照片多大多少厘米(手机做二寸电子版照片推荐)

证件照的使用在人们的日常生活中很普遍,其实,不少人觉得去店里做证件照既麻烦还得花钱,所以都选择使用证照之星。那么大家知道怎么设置证件照规格吗?1.打开证照之星,...

teamviewer免费办可以用多久(用手机远程控制另一台手机

teamviewer是德国开发的一款穿透内网的远程控制软件,和国内网络人远程控制软件相比,但是它功能强大,界面友好,获得了大量用户的认可。但是teamviewe...

兰蔻化妆品好吗,90%的人用过都说好

兰蔻作为一个来自法国的奢侈品护肤品牌,相信都已经早已能耳听能详了,其不仅在护肤品上有一番作为,从脸部护肤到口红再到香水,它家都有非常热门并具有代表性的产品,所以...

关键词排名推荐软件(提升关键词排名seo软件)

关键词的重要性不言而喻。无论是广告还是自然搜索排名都跟关键词有关,它关系着listing的权重,甚至会影响销量。而且研究显示亚马逊上大部分买家搜索产品往往不带品...

1080i和1080p有什区别,两者的画质对比分析

我们上网看视频的时候经常会在画质选项中看到480P、720P、1080P等选项,那么这后面的P代表了什么意思呢?我们看到的视频本质上就是一张一张的图片,比如10...

人工智能创业项目有哪些,怎样投资人工智能赚钱

教育领域的人工智能俞敏洪接受记者采访时曾说:“人工智能的发展,在教育上的应用比用在世界上任何一个领域都更加有效……凡是用人工智能,包括大数据、区块链等技术,在学...

oracle数据库登录命令(linux下重启oracle面试题)

苹果电脑终端连接oracle数据库常用操作1,访问服务器sshroot@192.0.0.0输入你的密码2,切换到oracle用户su&–oracle...

关键词优化过程,优化关键词有哪些方法

根据跨境电商平台亚马逊的A9算法,关键词是具有一定搜索权重的,而对于卖家而言,关键词则是吸引买家眼球的一个关键部分,优质的关键词能给listing带来较高的曝光...

idc是什么意思,idc的定义及发展

IDC主机托管主要应用范围是网站发布、虚拟主机和电子商务等。比如网站发布,单位通过托管主机,从电信部门分配到互联网静态IP地址后,即可发布自己的www站点,将自...

什么是创业,创业者和商人的区别

创业者与生意人,在常人看来好像也没有什么区别,但在光老看来创业者与生意人存在本质的区别。下面光老就从车载养花的创业与合作过程来谈谈自己的感受。光老的车载养花创业...