How to get date values from field collection to a node? I am trying to print the values from a field collection using following code in Drupal 7 node.But the date values are not getting.

$wrapper = entity_metadata_wrapper('node', $node);
 $formtype = field_get_items('node', $node, 'field_latest_schedules');
 foreach($formtype as $itemid) { 

 $item = field_collection_field_get_entity($itemid);

 print $item-&gt;field_course_starts_on['und'][0]['safe_value'];
 print $item-&gt;field_course_ends_on['und'][0]['safe_value'];

 }


How can i print the date from a filed collection?
I suppose that field_course_starts_on and field_course_starts_on are fields that represent date and you want to print it as date. Correct me if I'm wrong.

So you can print those fields as date like:

print date('d F, Y', $item-&gt;field_course_starts_on['und'][0]['safe_value']);
print date('d F, Y', $item-&gt;field_course_ends_on['und'][0]['safe_value']);


The part 'd F, Y' is a date format. Take a look at PHP Documentation to see all options for format parameter.

Update

First you have to load the ids of the field collection fields of the node:

$formtype = field_get_items('node', $node, 'field_latest_schedules');

// Extract the field collection item ids
$ids = array_column($formtype, 'value');
foreach ($formtype as $ft_field) {
    $ids[] = $ft_field['value'];
}


To iterate over all fields you can use the following code:

//Get the entities
$collections = field_collection_item_load_multiple($ids);

//Loop over the array - if you have more than one entity
for ($i = 1; $i &lt;= sizeof($collections); $i++) {
    $collection = $collections [$i];

    //Iterate over all member vars of the FieldCollectionItemEntity object
    foreach($collection as $key =&gt; $value) {
        //Look for fields - there are some other class vars, too.
        if (strpos ($key, 'field') !== false) {
            //Search for textfields 
            if (isset($value['und']) &amp;&amp; is_array($value ['und']) &amp;&amp; isset($value['und'][0]['value'])) {
                print "Field ".$key." ".$value['und'][0]['value'];
            }
        }
    }                   
} 


And than debug, target wanted fields and print those fields' values.