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 8384771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:29:32+00:00 2026-06-09T17:29:32+00:00

puts date — #{date} @date = Time.parse(date.to_s).iso8601 unless date.nil? puts @date — #{@date} Outputs

  • 0
puts "date --- #{date}"
@date = Time.parse(date.to_s).iso8601 unless date.nil?
puts "@date -- #{@date}"

Outputs

Date --- 2012-08-12T12:15:17-07:00
@Date -- 2012-08-12T19:15:17+00:00

Anyone know why?

Additionally, this happens with strptime

Time.strptime("2012-08-12T12:05:08-07:00", "%Y-%m-%dT%H:%M:%S%:z")
=> 2012-08-12 19:05:08 +0000
  • 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-09T17:29:34+00:00Added an answer on June 9, 2026 at 5:29 pm

    It appears that your system is set to UTC. Time.parse() creates a new Time object, which uses the system timezone, and sets it to the time that is parsed. It doesn’t change the timezone of the new Time to match the timezone of the parsed date. If you really want that behavior, you can use something like:

    DateTime.parse(date.to_s).new_offset(date.iso8601[-6,6]).iso8601
    

    Update: Regarding the strptime() part of the question that was just added, it’s the exact same concept. A new Time is being created with the default timezone, with a time that matches the date that you’re parsing.

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

Sidebar

Related Questions

I have an app that puts the date in the status bar, but in
I use chronic to return parsed date objects like so: last_pay_date = Date.parse(Chronic.parse('2011-11-04').strftime(%Y-%m-%d)) two_weeks_ago
jquery UI date picker puts a text on top of a button instead of
I would like a simple way to get yesterday's date (local time) as a
i have a script for a datepicker and it puts the date selected to
I wrote a function which creates a time_t from a time, date and time
I have this as expiry date $expiryDate = new DateTime(); But that puts expiry
I have a date picker for text field which puts in format of 5-MAY-2011
I am trying to write a function to format a date and time for
I'm working on a mobile website with jQuery Mobile. I know the framework puts

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.