Date time in so frickin annoying. I am simply trying to load a node programmatically and get it’s date time value. The default format is HTML5 Date, long date. However when I load it and get the field value it comes out like this:
dpm($ record['nid_value']); $ entity = \Drupal\node\Entity\Node::load($ record['nid_value']); dpm($ entity->get('field_date_range')->value);
Output
740 2018-02-23T02:00:00 734 2018-02-23T00:00:00
why the heck is it stored as 2018-02-23T02:00:00 when the real date is
Thursday – February 22, 2018 – 4:00pm to 5:00pm
Field type is “date range” and display type is “smart range”. When you view the node, it looks perfect. The display is correct. If I create a view, it also outputs the incorrect date, no matter what format I chose on the field output. Time zone has been forced.
Can anyone point me in the right direction here? Correct on display, wrong on load and in views