I'm creating a date field with a pop-up calendar and I'm attempting to use the format 'j M Y' (which looks like "23 Jul 2008"). However, the jQuery pop-up calendar does not seem to respect the 'M' part of that. If I have the field set to today as the default value, upon clicking on the field, the calendar appears, but… well, check out the screen shot. Upon clicking on Today, the dates for the current month appear and the widget works as normal; however, the text that appears in the text field has a format like "23 07 2008" (the month appears as a padded int). When the form is submitted, however, it reports that such a date is invalid.

This is happening in both Webkit and Gecko. I'm on PHP 4, if that matters (my company's D-list web host still hasn't upgraded). I tried both beta 3 and the dev release as of the time of this posting; no difference.

CommentFileSizeAuthor
Picture 29.png8.06 KBGarrett Albright
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Garrett Albright’s picture

If it's helpful, here's the code I'm using to create the form element. Please don't mind the weird way I'm storing the #default_value -- there's a method to that madness, really.

	$format = variable_get('chamber_news_date_format', 'j M Y');
		
	$form = array(
		…
		'ed_date' => array(
			'#type' => module_exists('date_popup') ? 'date_popup' : 'date_select',
			'#title' => t('Edition date'),
			'#default_value' => format_date(
				count($node->taxonomy) ? array_shift(explode(':', $node->taxonomy[0]['name'])) : time(),
				'custom',
				$format
			),
			'#date_format' => $format,
			'#required' => TRUE,
		),
		…
KarenS’s picture

Status: Active » Fixed

The jcalendar widget can't use that format. It uses only a very small set of formats, like Y-m-d, m/d/Y, d.m.Y. I don't have any control over that, that's the way it works. If you select a format in the UI you'll see that you're limited to those formats and aren't allowed to create a custom format for it.

Garrett Albright’s picture

I see. I guess JavaScript needs a library which can emulate PHP's date() function… if only I had all the time in the world.

KarenS’s picture

Not so much what javascript can do as that the author of the jQuery calendar widget didn't allow for any other format. It may be a translation issue since the allowed values are all things that don't require translation.

KarenS’s picture

Well, good news! I just updated the D6 version to the latest jquery datepicker code and it now allows more format options. You can now use 'M'. This won't work in the older jQuery code that I have to use in the D5 version, but will work in D6.

Garrett Albright’s picture

Excellent. When I get back into the office on Monday, I'll give it a try.

Garrett Albright’s picture

Excellent, the new calendar works perfectly with that format. (Well, there's some cosmetic issues, but those might be my fault.) Thank you.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.