I'm trying to build my own output for a date field *see Group multiple times by day (multi-value date field) *, but the problem I'm having is how to apply the timezone?
This article -> Date value to different date format and nearly every other reference out there tells me that it should be applied by default. But it isn't.
What I'm doing is theming the field with:
function theme_field__field_times($vars){
$dates = $vars["element"]["#values"];
foreach($dates as $item){ // there are many dates, so we'll cycle through each one
$date = ('U', strtotime($item['value'])); // convert to unix time
print('This date renders as: '.format_date('$date', 'custom', 'D d/m/Y - g:ia', '', date_default_timezone_get());
}
}
Which outputs, for example, 27/07/2011 -1:10pm. The value should be 27/07/2011 - 11:10pm, or the date that my function spat out +10hours - the timezone ('Australia/NSW') that should have been applied...
date_default_timezone_get() is returning the correct timezone.
If I let Drupal render the dates using it's default field theming, the dates are right.
So why isn't the timezone being applied? How do I fix it?