jQuery datepicker - 更改“今天”日期? [英] jQuery datepicker - change "today" date?

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

问题描述

有没有办法更改jquery.ui datepicker中的今日日期?
今天,我的意思是今天(class =ui-datepicker-today),而不是minDate或当前选择的日期!



我想到了,该datepicker使用系统时间作为默认值。现在我从服务器获取当前日期,并将其设置为我的minDate。但是我没有找到一种方法来设置今天的日期...
它仍然使用我的系统日期(有一些用户在那里,系统日期是在2000年或更早)。



可以帮助我吗?

解决方案

根据,它不看起来不错。

  var today = new Date(); 

这将永远是用户的系统日期。



如果你绝对必须解决这个问题,往下看一行;您可以覆盖 $。datepicker._daylightSavingAdjust 并从服务器返回日期*



但这是一个坏主意。为什么你的用户的系统日期变得如此混乱?为什么是你的问题?如果他们抱怨,请告诉他们修理他们的时钟。



*我不能强调这个想法有多糟糕。该函数用于对datepicker中的大部分日期进行规范化,因此您必须编写一些非常复杂的逻辑来防止所有事情的变化。这可能甚至不可行。


Is there a way to change the "today" date in jquery.ui datepicker? With today, I mean today (class="ui-datepicker-today") and not the minDate or the current-selected date!

I figured out, that datepicker uses the system time for default values. Now I get the current date from my server and set it to my minDate. But I didn't find a way to set the today-date... It still uses my system date (there are some users out there whose systemdate is in the year 2000 or earlier).

Can U help me plz?

解决方案

Based on the source, it doesn't look good.

var today = new Date();

That is always going to be the user's system date.

If you absolutely must fix this, look down a line; you could override $.datepicker._daylightSavingAdjust and return the date from your server *

But this is a bad idea. Why on earth do your users have their system date so messed up? Why is that your problem? If they complain, tell them to fix their clocks.

* I can't emphasize how bad an idea this is. That function is used to normalize most of the dates in the datepicker, so you'll have to write some pretty convoluted logic to keep from messing everything up. That may not even be feasible.

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

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