Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9168123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:33:26+00:00 2026-06-17T15:33:26+00:00

How do I parse this time zone string into it’s proper format so that

  • 0

How do I parse this time zone string into it’s proper format so that I can use Time.zone = <the proper time zone string>". Currently the known format type is: Eastern Time (US & Canada), Not sure why it doesn’t want to accept an even more precise format, like “(GMT-05:00) Eastern Time (US & Canada)”.

Are there any built-in tools in Rails to handle the string I have, and munge it into the proper Time.zone format? Note, the solution should map out correctly to ALL of Rail’s Time Zones list…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:33:27+00:00Added an answer on June 17, 2026 at 3:33 pm

    Not sure where you are getting your zone string, but check this TimeZone.to_s

    # Returns a textual representation of this time zone.
    def to_s
      "(GMT#{formatted_offset}) #{name}"
    end
    
    # Returns the offset of this time zone as a formatted string, of the
    # format "+HH:MM".
    def formatted_offset(colon=true, alternate_utc_string = nil)
      utc_offset == 0 && alternate_utc_string || self.class.seconds_to_utc_offset(utc_offset, colon)
    end
    

    All you need is Time.zone.name # => "Eastern Time (US & Canada)"

    If you don’t have that then parse the string with regex

    '(GMT-05:00) Eastern Time (US & Canada)'.match(/\(.*\) (.*)/)[1]
    #=> "Eastern Time (US & Canada)"
    

    https://github.com/rails/rails/blob/5fe88b11f11bb3b30bc23c57b36be4f027d915ba/activesupport/lib/active_support/values/time_zone.rb#L337

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Looking for a method that convert time string into Calendar look like this:
i'm looking to parse the real time rates from this webpage: http://www.truefx.com/ into my
What is the best way to parse time from a string? Example string: this
I'm trying to parse this XML string: <?xml version=1.0 encoding=UTF-8 standalone=no?> <response type=success> <lots>
I am trying to format a calendar string to indicate a time zone offset
I am having this trouble in converting the exiting time string into a new
I parse time from string in format HH:mm with java.text.SimpleDateFormat . For example 10:30
How can i parse this XML with C# WP7 to different lists for binding
I've got this time stored as a string: 2010-07-25 04:16:25 This is the GMT
I am looking for a PHP class that can parse an ICalendar (ICS) file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.