0

We want the date field to default to today's date when creating a new article. In the node edit form it defaults to the date set in the content type field settings. In the field settings form, it says "leave blank to use the time of form submission". If we leave it blank, it saves the form submission time which is then the new default for the node edit form.

How do we make the date field in the node edit form always show today's date for new content?

field settings

  • Is that a new field you added or the node created field? – mpdonadio Dec 20 '17 at 16:15
  • Some clarification: We are actually using the standard Timestamp field and not the Date field. When creating the Date field it allows using "Current time" while the Timestamp field defaults to the time of the field settings form was saved. – Jacob Pedersen Dec 22 '17 at 7:55
1

If already date field created follow the below steps to change the date formate:

  1. Goto particular Content type, which you have created.

admin/structure/types/manage/{CONTENTTYPE_MAHINE_NAME}

  1. click on the 'Manage Fields' form the tab menu

  2. click on the 'edit' button on the date field of the content type. The field settings will open, the link will be

/admin/structure/types/manage/{CONTENTTYPE_MAHINE_NAME}/fields/node.{CONTENTTYPE_MAHINE_NAME}.field_{FIELD_MACHINE_NAME}

Goto bottom of the page

  1. Select the 'Current date' option from the drop down at the section of 'default value'.

  2. To display only the date without time, goto 'Field settings' and select the 'date only' option from the drop down of 'Date type'.

0

you can set it by code just implement form alter hook in your custom module and set your date like,

function example_form_alter(&$form, &$form_state, $form_id) {
  dsm($form_id);  // print form ID to messages
  if($form_id == "your contentype form-id"){ 
  if(!isset($form['your field name']){
  //set your field value as default current time
    $today = date('d/m/Y');
    $form['your field name']["und"][0]['value']['#default_value']['value'] = $today;
  }
  }
}
0

You can setting config field {example.com}/admin/structure/types/manage/event/fields/{field_date}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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