How to use datepicker pop up in a form field in a custom module?

Ever needed to use datepicker pop up in a custom module? That would be the most usable way to allow users to choose a date.

Here is the code to be used in the form function:


$format = 'd-m-y';
  $form['date_from'] = array(
    '#title' => t('Date From'),
    '#type' => 'date_popup',
    '#date_format' => $format,
    '#description' => t('Please select a date'),
  );