Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
[SDPAP-9438]Fix date display issue for Promo cards
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-gao committed Jun 19, 2024
1 parent b862316 commit b5dbb91
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Helper/TideLandingPageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ class TideLandingPageHelper {
* The converted date.
*/
public static function localDateAndTimeFormatter($date) {
// Parse date with GMT timezone.
$storage_tz = DateTimeItemInterface::STORAGE_TIMEZONE;
$drupal_date_time = new DrupalDateTime($date, $storage_tz);
// Convert to local timezone.
$system_tz = \Drupal::service('config.factory')->get('system.date')->get('timezone.default');
$date_formatter = \Drupal::service('date.formatter');
$converted_date = $date_formatter->format($drupal_date_time->getTimeStamp(), 'custom', 'Y-m-d H:i:s', $system_tz);
return $converted_date;
if (!empty($date)) {
// Parse date with GMT timezone.
$storage_tz = DateTimeItemInterface::STORAGE_TIMEZONE;
$drupal_date_time = new DrupalDateTime($date, $storage_tz);
// Convert to local timezone.
$system_tz = \Drupal::service('config.factory')->get('system.date')->get('timezone.default');
$date_formatter = \Drupal::service('date.formatter');
$converted_date = $date_formatter->format($drupal_date_time->getTimeStamp(), 'custom', 'Y-m-d H:i:s', $system_tz);
return $converted_date;
}
}

}

0 comments on commit b5dbb91

Please sign in to comment.