[development] date/time and timezone handling

ad4m adam at ludwinski.net
Fri Mar 11 10:58:07 UTC 2011


Hello Blake,

Try using Date (http://drupal.org/project/date) module which gives you
support for per-user timezones.

--
Kindest regards,
Adam Ludwinski
Weever Web Warehouse
mobile: +48 606 107 297
adam.ludwinski at weever.net
http://www.weever.net
Al. Jerozolimskie 87 piętro 2
02-001 Warszawa


____________________________________________

Niniejsza wiadomosc wraz z ewentualnymi zalacznikami jest poufna i
stanowi prawnie zastrzezona korespondencje przeznaczona wylacznie dla
jej odbiorcy. Jesli odbiorca tej wiadomosci nie jest jej adresatem,
niniejszym informujemy, ze otrzymali ja Panstwo omylkowo. W zwiazku z
tym prosimy o niezwloczne powiadomienie o tym nadawcy zwrotna poczta
elektroniczna oraz o usuniecie otrzymanej wiadomosci wraz z
ewentualnymi zalacznikami.

This e-mail message with any attached files is confidential and as a
legally privileged correspondence is assigned exclusively for
recipient. If you are not intended recipient we inform that delivery
is made by mistake. Please notify the sender immediately and then
delete this e-mail with all attachments.
____________________________________________



On 11 March 2011 03:56, Blake Senftner <bsenftner at earthlink.net> wrote:

> Does anyone have any advice or a good tutorial for working with timestamps,
> and user configurable timezones within Drupal 6?
>
> I have analytics data being recorded, each event with a timestamp generated
> via time(), so it's a standard Unix timestamp.
>
> Previously, I think I had the analytics being reported correctly for each
> user in their local timezone via:
>
> $timeStr = format_date($action->timestamp, 'custom', $customTimeFormatStr,
> variable_get('date_default_timezone', 0));
>
> But when I added analytics exporting, with the user being able to specify a
> start and end date/time string, I began to suspect that the above timezone
> handling is incorrect.
>
> Given:
> $start = '7 am';
> $timecode = strtotime( $start );
> $start = format_date( $timecode, 'custom', 'h:i:s a, d M
> Y', variable_get('date_default_timezone', 0));
>
> I get $start is "11:00:00 pm, 10 Mar 2011' <- wrong time, correct date
>
> However, changing the format_date() call to be like this:
>
> $start = format_date( $timecode, 'custom', 'h:i:s a, d M Y', 0);   <-
> changed variable_get() to 0
>
> Gives me "07:00:00 am, 11 Mar 2011"  <- correct time, but one day in the
> future
>
> Leaving the timezone parameter off, letting it's default NULL value be used
> like this:
>
> $start = format_date( $timecode, 'custom', 'h:i:s a, d M Y');
>
> Gives me "12:00:00 am, 11 Mar 2011"  <- wrong time plus one day in the
> future
>
> I guess I could just use the second form, with the timezone parameter set
> to zero, and recommend that users include the date, but it sure is
> convenient to just say "12:00:00 am" and "12:59:59 pm" to capture the
> analytics thus far for the day.
>
> Perhaps my date time configuration for the site is incorrect?
> At admin/settings/date-time I have the time zone set correctly, and user
> configurable timezones are enabled. BTW, the users of the site are
> international, with people on both east & west coast US, London, Israel, and
> India. So the timezone handling is important.
>
> Sincerely,
> -Blake
> bsenftner at earthlink.net
> www.BlakeSenftner.com
> www.MissingUbercartManual.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110311/69123801/attachment.html 


More information about the development mailing list