Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
403 views
in Technique[技术] by (71.8m points)

jquery - jQuery UI DatePicker-更改日期格式(jQuery UI DatePicker - Change Date Format)

I am using the UI DatePicker from jQuery UI as the stand alone picker.

(我正在使用jQuery UI的UI DatePicker作为独立的选择器。)

I have this code:

(我有以下代码:)

<div id="datepicker"></div>

And the following JS:

(和下面的JS:)

$('#datepicker').datepicker();

When I try to return the value with this code:

(当我尝试使用以下代码返回值时:)

var date = $('#datepicker').datepicker('getDate');

I am returned this:

(我得到这个:)

Tue Aug 25 2009 00:00:00 GMT+0100 (BST)

Which is totally the wrong format.

(这是完全错误的格式。)

Is there a way I can get it returned in the format DD-MM-YYYY ?

(有没有办法让我以DD-MM-YYYY格式返回它?)

  ask by tarnfeld translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here's one specific for your code:

(这是针对您的代码的一种:)

var date = $('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' }).val();

More general info available here:

(此处提供更多常规信息:)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...