Skip to content

Commit

Permalink
Merge pull request #1148 from tripal/1147-tv3-datetime
Browse files Browse the repository at this point in the history
Datetime Fields Showing Wrong Date
  • Loading branch information
spficklin committed Jan 21, 2021
2 parents 41b300f + 7d883e7 commit 14c83a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tripal_chado/includes/tripal_chado.field_storage.inc
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,16 @@ function tripal_chado_field_storage_load($entity_type, $entities, $age,
// as the column value.
$entity->{$field_name}['und'][0]['value'] = $record->$field_column;
$entity->{$field_name}['und'][0]['chado-' . $field_table . '__' . $field_column] = $record->$field_column;

// For datetime columns we need to strip out the milliseconds if
// they are there because the Drupal date field can't deal with
// miliseconds and causes the displayed time to rever to the
// current time.
if ($field_type == 'datetime') {
$datevalue = $entity->{$field_name}['und'][0]['value'];
$datevalue = preg_replace('/^(\d+-\d+-\d+ \d+:\d+:\d+)\.\d+$/', '\1', $datevalue);
$entity->{$field_name}['und'][0]['value'] = $datevalue;
}
}
}

Expand Down

0 comments on commit 14c83a9

Please sign in to comment.