Forum: Ruby on Rails Getting the timezone (the GMT offset) from DateTime

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fbd9cb107fe7c941333d6a3488691989?d=identicon&s=25 Ramon Tayag (ramontayag)
on 2007-06-16 08:39
(Received via mailing list)
Hi everyone!

How do you get the timezone (in the format: +0800) from a time object?

Please see http://pastie.caboo.se/70979

Thank you,
--
Ramon Tayag
8608f2d7f02c6d0f1c349b7b94b1cea5?d=identicon&s=25 liquidautumn (Guest)
on 2007-06-16 09:55
(Received via mailing list)
%z will do the job, but...
are you sure you are doing timezone related stuff in a right way?
usually it is better to store your times in UTC timezone, converting
back and forth to user's, user location's or whatever entity's you'll
find appropriate local timezone.

On Jun 16, 9:38 am, "Ramon Miguel M. Tayag" <ramon.ta...@gmail.com>
Fbd9cb107fe7c941333d6a3488691989?d=identicon&s=25 Ramon Tayag (ramontayag)
on 2007-06-16 16:40
(Received via mailing list)
%z gives me "Malay Standard Pacific Time" (or something like that).  I
figured it'd be much easier to make a timezone drop down (just like
all the other sites out there).

"are you sure you are doing timezone related stuff in a right way?"
-- Not at all :o

Thanks :)

On 6/16/07, liquidautumn <denis@talentboom.com> wrote:
> >
>
--
Ramon Tayag
61e256a6406e159adbfd3535731f72ab?d=identicon&s=25 kates (Guest)
on 2007-06-22 19:14
(Received via mailing list)
Try Time.new.localtime.strftime "%z" ?
Fbd9cb107fe7c941333d6a3488691989?d=identicon&s=25 Ramon Tayag (ramontayag)
on 2007-06-23 20:06
(Received via mailing list)
Thanks, kates, will do :)

On 6/23/07, kates <katesgasis@gmail.com> wrote:
>
> Try Time.new.localtime.strftime "%z" ?

--
Ramon Tayag
This topic is locked and can not be replied to.