0

I need to hook into the time zone pipeline before date display to properly calculate "local" time events. It seems Drupal provides site and user time zone settings (and Views has its own TZ control for date time) but none of those are applicable. Since Drupal stores datetime in UTC(a fixed point), I need to display datetimes using offsets for local time. That is, UTC=12345678ms, New York will be -5 and Los Angeles will be -8 off of it. When viewing/editing entities where events occur in -5, the dates displayed are (UTC-5hr) and events that occurred in LA at precisely the same time (12345678ms) are UTC-8hr. So neither system/user or Views TZ settings apply. A Views report must show local times where events/alarms occur, not system/user/Views time zones. Where can I hook into the pipeline to accomplish this?

  • 1
    I don't think you should process every date. You can set the timezone for the whole system, and every user can have their own timezone. Drupal takes care of showing the proper time to each user with those settings. I think you should explain your initial problem. It seems that you are asking how to implement a certain solution for a problem you don't explain, maybe there're other solutions closer to the Drupal way. It's better to explain the original problem so we can suggest you a proper solution. – sanzante Jan 8 at 14:13
  • Hi sanzante, To state the problem, my requirements are such that system and user time zones won't work as I'm trying to display precisely the time an event occurred in a specific time zone (not relative to system location or user time zone). Example: You are in your home and two events occur one minute apart on the globe (let's say East Coast US and West Coast US) Drupal must create nodes with timestamps that are in each of the respective zones (not UTC) So, when you view/edit the nodes they are timestamped for their zones (not your TZ or systems). Any other way to solve this? – Scott Jan 13 at 16:09
  • Sorry, forgot to mention I know Drupal stores all dates in UTC. Say you have 3 homes, New York City, Denver and Los Angeles. 3 Entity nodes in Drupal called Homes. Each home has its own Timezone field. Incidents occur at each home and are recorded in an entity referenced detail record. When you "Views" your incident report, the date/time that displays is for the time at the home(s) not your user TZ or the system TZ. So any date displayed anywhere (node view/edit, Views) must be shown based on the home's TZ only. – Scott Jan 13 at 16:32
  • I see. I think you should edit your question (title and body) to explain this. I guess your question is more "How to display a date field value without TZ applied" than using a custom date function. – sanzante Jan 14 at 9:56
  • Thanks and will do. Must think on how to state it as date fields must pass through my own TZ application, not core user/system/views. – Scott Jan 14 at 11:28

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.