mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
fix to_time
output in ActiveSupport guide. Since 48583f8bf7
, to_time returns times formatted as YYYY-MM-DD HH:MM:SS UTC [ci skip]
`to_time` method returns in `YYYY-MM-DD HH:MM:SS UTC` format after this commit 48583f8bf7
.
This commit is contained in:
parent
e299b515ca
commit
a2f78cb947
1 changed files with 3 additions and 3 deletions
|
@ -1865,15 +1865,15 @@ The methods `to_date`, `to_time`, and `to_datetime` are basically convenience wr
|
|||
|
||||
```ruby
|
||||
"2010-07-27".to_date # => Tue, 27 Jul 2010
|
||||
"2010-07-27 23:37:00".to_time # => Tue Jul 27 23:37:00 UTC 2010
|
||||
"2010-07-27 23:37:00".to_time # => 2010-07-27 23:37:00 +0200
|
||||
"2010-07-27 23:37:00".to_datetime # => Tue, 27 Jul 2010 23:37:00 +0000
|
||||
```
|
||||
|
||||
`to_time` receives an optional argument `:utc` or `:local`, to indicate which time zone you want the time in:
|
||||
|
||||
```ruby
|
||||
"2010-07-27 23:42:00".to_time(:utc) # => Tue Jul 27 23:42:00 UTC 2010
|
||||
"2010-07-27 23:42:00".to_time(:local) # => Tue Jul 27 23:42:00 +0200 2010
|
||||
"2010-07-27 23:42:00".to_time(:utc) # => 2010-07-27 23:42:00 UTC
|
||||
"2010-07-27 23:42:00".to_time(:local) # => 2010-07-27 23:42:00 +0200
|
||||
```
|
||||
|
||||
Default is `:utc`.
|
||||
|
|
Loading…
Reference in a new issue