Opened 14 years ago

Closed 14 years ago

#4514 closed bug (fixed)

IE7/8 dateFormat option messing up default year

Reported by: quasipickle Owned by:
Priority: major Milestone: 1.8
Component: ui.datepicker Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:


In IE7/8, when opening a datepicker in dialog mode, and the defaultDate option is set as a Date object, the year is read incorrectly if the dateFormat option is set.

Test page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type = "text/javascript" src = ""></script>
<script type = "text/javascript" src = "ui.core.js"></script>
<script type = "text/javascript" src = "ui.datepicker.js"></script>
<script type = "text/javascript">
	var oDate = new Date();


			dateFormat:'D M dd yy'			
<input id = "test" type = "text" />

This code, when run in Firefox, will produce a datepicker dialog with 2009 as the current year. In IE, the current year will be 2016. I believe this stems from the fact that the Date object, when output as a string, appears different in IE & Firefox.

In Mozilla: Fri May 04 2009 16:50:05 GMT-0600 (MDT)
In IE: Fri May 4 16:50:05 MDT 2009

I believe the problem lies in _parseDate() & stems from the fact it tries to determine the date by pulling the date-as-a-string apart, rather than using the functions built into the Date object. However, this is my first time looking at the datepicker code, so I may be way off base.

Change History (4)

comment:1 Changed 14 years ago by quasipickle

I think if toUTCString() is used rather than toString(), that should fix it.

comment:2 Changed 14 years ago by Jörn Zaefferer

Milestone: TBD1.7.2

comment:3 Changed 14 years ago by Jörn Zaefferer


comment:4 Changed 14 years ago by kbwood

Resolution: fixed
Status: newclosed

The dialog command expected a string version of the date and so didn't know what to do with a Date object. This has been updated to accept either. Fixed in r2696.

Note: See TracTickets for help on using tickets.