I have a webform where the user also submits date. I would like to populate a date type field with the submitted date. I tried making variable by "Add variable", but I do not know how to access my webform submission.
Later I realised that I need to run a custom php code, so I wrote this, which actually works:
// use the submitted time value from the webform and convert it to time, also use it for an end date one year later $time = strtotime($data['components']['submitted time']['value']); $time2 = strtotime('+1 year', $time); //convert to date formats to the format used in these fields $startdate = date('Y-m-d',$time); $enddate = date('Y-m-d',$time2); //update the field values and save the updates $new_user_request -> field_start['und']['value'] = $startdate; $new_user_request -> field_end['und']['value'] = $enddate; user_save($new_user_request);
Hopefully this helps someone else too.