0

I realize that similar questions have been asked multiple times, but find that either the answers aren't what I am looking for or the specifics of the question aren't the same.

I want to create a custom date format for two different date fields within a specific Webform (not globally). The first date field is the submission date and the second is a date of birth field that we added.

I have created the desired custom date formats in admin/config/regional/date-time/formats let's call them A and B. Then I created custom date types using those formats in admin/config/regional/date-time.

I cannot find where to apply date type "A" to submission dates for the webform and I cannot find where to apply date type "B" to my custom date of birth field within the webform.

Submission Date:

Format A: Y-m-d - H:i This appears to be an internal field, as it doesn't show up in my list of webform fields. I checked form settings and in advanced form settings as well as in form components.

Date of Birth Date:

Format B: Y-m-d This is a custom field. When I click "edit" for this field, I don't see where to specify how the date format will be recorded.

Furthermore, it isn't important to me how these dates look when viewed on the survey or on the screen but they need to be recorded so that they are in the downloaded data in the specified format.

0

2 Answers 2

1

It seems that the only way to make this happen was to reset the system's Short Date Format to my custom format A. Thankfully, the webform custom DOB field uses a similar format (the same thing but without the hour and minutes.)

If anyone knows a better way where I could have done this on a "per form" and "per field" basis, please add your answer as the one I am providing now isn't really what I was looking for.

0

Just create custom date formate it would be like this

if(isset($record['doc_date']))
{
$date = explode(" ",$record['doc_date']);
$d_date = date("d-m-Y",strtotime($date[0]));
} 

and create date field

$form['doc_date'] = array(
    '#type' => 'date',
    '#required' => TRUE,
    '#date_date_format' => 'd-m-Y',
    '#default_value' => (isset($record['doc_date']) && $_GET['num']) ? $d_date:'',

i hope it would work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.