Skip to main content
added 29 characters in body
Source Link
berramou
  • 7.3k
  • 2
  • 13
  • 31

Based on @berramou answer, I think this would be the right way (timezone and format wise):

->setDefaultValue(DrupalDateTime::createFromTimestamp(\Drupal::time()
      ->getRequestTime(), DateTimeItemInterface::STORAGE_TIMEZONE)
      ->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT))

Based on @berramou answer, I think this would be the right way (timezone and format wise):

->setDefaultValue(DrupalDateTime::createFromTimestamp(\Drupal::time()->getRequestTime(), DateTimeItemInterface::STORAGE_TIMEZONE)->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT))

Based on @berramou answer, I think this would be the right way (timezone and format wise):

->setDefaultValue(DrupalDateTime::createFromTimestamp(\Drupal::time()
      ->getRequestTime(), DateTimeItemInterface::STORAGE_TIMEZONE)
      ->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT))
Source Link
pcambra
  • 2.5k
  • 1
  • 15
  • 23

Based on @berramou answer, I think this would be the right way (timezone and format wise):

->setDefaultValue(DrupalDateTime::createFromTimestamp(\Drupal::time()->getRequestTime(), DateTimeItemInterface::STORAGE_TIMEZONE)->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT))