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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:43:47+00:00 2026-06-16T04:43:47+00:00

I have a project model with a datetime attribute to define the deadline. The

  • 0

I have a project model with a datetime attribute to define the deadline. The deadlines are of different time zones, and I receive them in a string format like below:

Jan 1st 2013 00:00:00 EST
Feb 9th 2013 23:59:00 PST

I want to store these values in the default UTC format in the database. I’ve seen that there are many options to parse the time like Time.zone.parse and Time.parse. My question is: what’s the best practice to parse the datetime of different time zones? I’m using Rails 3.2.9.

  • 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-16T04:43:48+00:00Added an answer on June 16, 2026 at 4:43 am

    You need not worry about that at all, as long as you set correct timezone in config/application.rb:

    config.time_zone = 'UTC'
    

    You just assign the time strings to the attributes, ActiveRecord will convert it correctly.

    1.9.3p125 :002 > project.deadline = "Jan 1st 2013 00:00:00 EST"
     => "Jan 1st 2013 00:00:00 EST" 
    1.9.3p125 :003 > project.deadline
     => Tue, 01 Jan 2013 05:00:00 UTC +00:00 
    1.9.3p125 :004 > project.deadline = "Feb 9th 2013 23:59:00 PST"
     => "Feb 9th 2013 23:59:00 PST" 
    1.9.3p125 :005 > project.deadline
     => Sun, 10 Feb 2013 07:59:00 UTC +00:00 
    

    ActiveRecord uses Time.zone.parse to parse the strings internally.

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

Sidebar

Related Questions

I have a project which exposes object model to use by different types of
Hi I have a model like so: from datetime import datetime class Project(models.Model): created
I have this Project model: class Project < ActiveRecord::Base validates :status, :inclusion => {
I have a Project model similar to: class Project(models.Model): ... lead_analyst=models.ForeignKey(User, related_name='lead_analyst') ... I
I have a Project model and it has some text attributes, one is summary.
I have a M2M field in my django model project. In my view I
In my project I have a model where I use Imagekit to process an
I have a Java project that I'm trying to implement with a model-view-controller design.
I have a Python project with following directory structure: /(some files) /model/(python files) /tools/(more
I have an existing model for my project. I would like to switch to

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.