문제

In my fixtures for unit testing, I have something like this:

time: <%= Time.now %>

This will give me the time based on the machine's time zone. I want to get the time in UTC, I tried this:

time: <%= Date.tomorrow.in_time_zone('UTC') %>

It says, in_time_zone is undefined. How can I get the UTC date/time in the fixtures?

Thanks,

도움이 되었습니까?

해결책

It will show current time in UTC:-

Time.now.utc

Example:--

1.9.3-p385 :003 > Time.now.utc
=> 2014-04-25 19:29:03 UTC 
1.9.3-p385 :004 > 

다른 팁

Try giving like this

<%= Time.now.utc.in_time_zone %>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top