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

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

问题描述

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

 < div id =datepicker>< / div> 

以下JS:

  $('#datepicker')。datepicker(); 

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

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

我已退回:

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

这是完全错误的格式。有没有办法可以以格式 DD-MM-YYYY

解决方案/ div>

这是一个特定的代码:



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



更多一般信息在这里:




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

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

And the following 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?

解决方案

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天全站免登陆