Hi,

I'm creating a custom node module. I have included a textfield form item, Exam_Date to which is attached the javascript pop calendar (obtained using jstools module). This was done using the example provided in the readme.txt in the jscalendar folder.
I would like the input value in this field to be

26/07/2007 - 9:30pm.

My code is


  $form['exam_date'] = array(
    '#type' => 'textfield',
    '#attributes' => array('class' => 'jscalendar'),
    
    '#jscalendar_ifFormat' => '%Y-%m-%d %h:%i %A',
    
    '#jscalendar_showsTime' => 'true',
   
    '#jscalendar_timeFormat' => '12',
  );


I know I need to set the #jscalendar_ifFormat to the custom format string that would give the indicated format.(using the format parameters defined at http://php.net/date).

This string, i think, should be '%Y-%m-%d %h:%i %A' as shown above. However, the %h, %i and %A are not being recognized. I've tested other format parameters...from the list given at http://php.net/date. ..

The output that is obtained is not what is expected, as listed in the doc. Has anyone experienced this before ? Is it a timezone issue ?? Any ideas on how to resolve this, that what parameters to use, if any , to get this format ....26/07/2007 - 9:30pm ??

Any help please...if you have come across this.....thanks alot...

Comments

dhar’s picture

any ideas on this ?? anyone ? really need to properly include the javascript calendar to get a date in my custom node module. Is there another good alternative ? please..

dhar’s picture

At last, I've been provided with tremendous help....from nevets...on this issue. Thanks to nevets for this answer/feedback.

Apparently, the format identifiers to use in creating custom date display formats using the javascript popup calendar is given at the author's site
http://www.dynarch.com/demos/jscalendar/doc/html/reference.html#node_sec...

In my case, I am using a 12 hour calendar. My aim is to get the date in the following display format
2007-07-11 01:00 PM

Therefore, the correct custom date format for this display is : '%Y-%m-%d %I:%M %p'.

The %I is used to get a 12-hour hour value, %M gives 0-59 minutes, %p gives AM or PM.

My corrected code is now:


$form['examdate'] = array(
    '#type' => 'textfield',
    '#attributes' => array('class' => 'jscalendar'),
    '#jscalendar_ifFormat' => '%Y-%m-%d %I:%M %p',
    '#jscalendar_showsTime' => 'true',
    '#jscalendar_timeFormat' => '12',
    
'#default_value' => $node->examdate,
  ); 

Thanks again to nevets for giving me these answers.