Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
i created a date field in file entity to collect the current date.
With a hook_form_alter, i tried to automaticaly insert the current date in this field when i add a file in Drupal.
I use this code:
function mymodule_form_alter {
$form['field_test']['und'][0]['#default_value'] = array (
'value' => format_date(strtotime('now'), 'custom', 'Y-m-d\TH:i:s', 'UTC'),
'#type' => 'date',
);
}
But, the generated date is different of the current date :
current date : 18/10/2013 - 16:19
generated date : 18/10/2013 - 16:15
I have a lag of a few minutes.
My timezone is Europe/Paris.
Thanks for your help.