Created
February 27, 2024 10:05
-
-
Save prashantdsala/a0cbb2a9e6e540ed1c18386d45f411ec to your computer and use it in GitHub Desktop.
Drupal: Get timestamp from date field and current time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drupal\Core\Datetime\DrupalDateTime; | |
// Check if the event's end date is not present | |
// or has been passed. | |
$current_time = new DrupalDateTime('now', 'UTC'); | |
if ($entity->get('field_event_end_date')->isEmpty() || ($current_time->getTimestamp() >= $entity->field_event_end_date->date->getTimestamp())) { | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment