How can I add to the class name of a form element?
I think it needs to be an array.

Try this:

$form['grant_opportunity_end_date']['#attributes'] = array('class' =&gt; array('datepicker'));


You can also call it directly from hook_form_alter().
For example in your themes template.php you could add:

function YOURTHEME_form_alter(&amp;$form, $form_state, $form_id)   {
  if($form_id == 'YOUR_FORM_ID') {
    $form['grant_opportunity_end_date']['#attributes'] = array('class' =&gt; array('datepicker'));
  }
  // this displays some general info so you can check
  drupal_set_message("Form ID is : " . $form_id);
  drupal_set_message(dprint_r($form, TRUE));
}