jQuery UI DatePicker - 更改日期格式 [英] jQuery UI DatePicker - Change Date Format

查看:34
本文介绍了jQuery UI DatePicker - 更改日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用来自 jQuery UI 的 UI DatePicker 作为独立的选择器.我有这个代码:

I am using the UI DatePicker from jQuery UI as the stand alone picker. I have this code:

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

以及以下 JS:

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

当我尝试使用此代码返回值时:

When I try to return the value with this code:

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

我被退回:

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

这是完全错误的格式.有没有办法让它以 DD-MM-YYYY 格式返回?

Which is totally the wrong format. Is there a way I can get it returned in the format DD-MM-YYYY?

推荐答案

这里有一个特定于您的代码:

Here's one specific for your code:

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

此处提供更多一般信息:

More general info available here:

这篇关于jQuery UI DatePicker - 更改日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆