如何使用jquery获取当前日期? [英] How to get current date using jquery?
本文介绍了如何使用jquery获取当前日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用日历插件,我想将当前日期填充到文本字段中。如何使用jquery来执行此操作?
I am using a calender plug-in and I want to populate the current date into a text field. How can I do this using jquery?
推荐答案
您可以获取 JavaScript中的当前日期:
var now = new Date();
如果您使用的是jQuery DatePicker ,您可以将其应用于任何这样的文本框:
If you are using jQuery DatePicker you can apply it on any textfield like this:
$('input.youTextFieldClass').datepicker({ dateFormat: 'mm/dd/yy',
changeMonth: true,
changeYear: true,
yearRange: '-70:+10',
constrainInput: false,
duration: '',
gotoCurrent: true});
$("input.youTextFieldClass").datepicker('setDate', new Date());
这篇关于如何使用jquery获取当前日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文