In node I have added one date field with date time. After that I have created one node and add value "06/05/2017 - 22:15" to date field and save it.

After that I have tried to access date field value in theme_preprocess_node() and getting different value "2017-06-05T16:45:00".

So How can I get value that I have entered in at the time of node create programatically in Drupal 8?

Please let me know if anyone work on it.

Comments

NitinSP created an issue. See original summary.

NitinSP’s picture

Issue summary: View changes
gg24’s picture

Hi @NitinSP,

Seems like your user timezone or may be system timezone is different. Please check it once as i see there is no issue with the date-time value from date field.

Thanks!

NitinSP’s picture

Hi @gg24,

Thanks for reply.

My system timezone is Asia/Kolkata and and I have setup drupal default timezone to country -UK and Europe/London.

I am using below custom code to fetch paragraph date field value

$dateStart = new DrupalDateTime($paragraph->get('field_start_date_time')->getString());
$offerStartTime = $date->format($dateStart->getTimestamp(), 'custom', 'm/d/Y H:i:s');

Is there any way to collect correct datatime value?