Question: 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`.

Answer: 
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.
When you run `Time.parse` it will convert the timestamp to your configured timezone in rails. For example, my rails app runs in EST.

```
[5] pry(main)> Time.parse('Jan 1st 2013 00:00:00 EST')
=> 2013-01-01 00:00:00 -0500
[6] pry(main)> Time.parse('Feb 9th 2013 23:59:00 PST')
=> 2013-02-10 02:59:00 -0500

```

Notice the `+3:00hrs` for the `PST` timestamp used to get the result into my EST timezone.

To get the UTC version of each timestamp, just call `utc`

```
[7] pry(main)> Time.parse('Jan 1st 2013 00:00:00 EST').utc
=> 2013-01-01 05:00:00 UTC
[8] pry(main)> Time.parse('Feb 9th 2013 23:59:00 PST').utc
=> 2013-02-10 07:59:00 UTC

```