How to set a value for a date field? I need to set a value for a date field with type datetime in hook_form_alter. I tried with below codes. But it is not working. 

$form["field_event_date"]["und"][0]['#default_value']['value'] = $new_date;
$form_state['values']['field_event_date']['und'][0]['value']['date'] = $new_date;
$form['field_event_date'][LANGUAGE_NONE][0]['#default_value']['value'] = $new_date;


This $new_date will be a value from another field in this form and it should be in '2014-09-23 00:00:00' format. And 'field_event_date' will be a hidden field.

I can save the value to this field using the node_presave function. Please see the below code. If anyone trying to save a value to a date field with a static value, you can use this method.

function MY_MODULE_node_presave($node) {
     $node-&gt;field_event_date['und'][0]['value'] =  '2014-09-23 00:00:00';
}


But in my case, I need to get the value from a field that defined in the form alter. And need to set this value to the field_event_date. Can anyone help me on this? Is there any way to get a custom field value in node_presave function?
To set a value to a date field follow below codes.

Using hook_form_alter

$form["field_event_date"]["und"][0]['#default_value']['value'] = $new_date;


Using hook_node_submit or hook_node_presave (Saving the value to the database)

 function MY_MODULE_node_presave($node) 
  {
      $node-&gt;field_event_date['und'][0]['value'] =  '2014-09-23 00:00:00';
  }


Or if you need to save value of one custom field(defined in hook_form_alter) to another, see below codes. 

function MY_MODULE_node_submit($node, $form, &amp;$form_state) {
  if($node-&gt;type == 'my_node_type') {
    $test_date =  $form['test_date ']['#value'];
    //Ensure that $test_date format is '2014-09-23 00:00:00'
    $node-&gt;field_event_date['und'][0]['value'] =  $test_date ;
   }
}


I think it may help anyone who is searching for the solution.