How to print a date from Date module using user timezone I would like to send an email out to a user when a new 'event' content type is posted. In this email, I want to display the title of the event, the body, and the date itself. For the date, I would like to print the date in the timezone of the user receiving the email.

So, when I send the email, I first get the user's account and the event node:

&lt;?php
  $account = user_load($uid);
  $event = node_load($nid);
?&gt;


I want to first check if the user has a timezone set in the user's profile, and if not, default back to the timezone used (and stored) with the event itself. So, something like:

&lt;?php
  $timezone = $account-&gt;timezone ? $account-&gt;timezone : $event-&gt;field_event_date[$event-&gt;language][0]['timezone'];
?&gt;


But, at this point, I'm not sure exactly how to print the date in the node in the correct timezone. I'm thinking I might have to first create a new DateTime object, then convert it using date.module's date_format_date, or maybe convert the date to a timezone, calculate the offset, and use PHP's date() function or format_date() to display the end result, but this all seems overkill.

Is there a simpler way to print out a date from a date field attached to a node in a user's timezone?

[Edit:]

I'm trying to format the date using format_date() or date_format_date(), but format_date() requires a time stamp, which is difficult to create from the date field's output, and date_format_date() also requires proper timezone information when I create a date object, and I've found it difficult to account for the timezone supplied by the date field, and then translate that into the timezone for output.

[Edit 2:]

Here's the code I ultimately used:

&lt;?php
  $event = node_load([nid]);
  // Build event date + timezone.
  $timezone = $account-&gt;timezone ? $account-&gt;timezone : $event-&gt;field_event_date[$event-&gt;language][0]['timezone'];
  date_default_timezone_set($event-&gt;field_event_date[$event-&gt;language][0]['timezone_db']);
  $date = strtotime($event-&gt;field_event_date[$event-&gt;language][0]['value']);
  $date_formatted = format_date($date, 'custom', 'M j, Y g:i a', $timezone);
?&gt;
The problem is the configuration of the date field itself. In its settings (field management->edit), you will find an option "Time zone handling". This option controls the way this field is parsed and its display. I will venture a guess that yours is set to "Site's time zone". This means, that the default timezone will be used to convert this datetime into UTC, and the same will be used to display it. If changed to "User's time zone" option, then user's timezone will be used instead, and the default one will be the fallback if none such is set. The latter is taken into account from the format_date() function, without your having to set the $timezone parameter explicitly. 

In your case, since each event has a timezone of its own, I would also consider the second option "Date's time zone". In this case, custom date timezone is not taken into account by format_date(), thus needs to be explicitly set. 

Read the complete documentation here