Question

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,

Was it helpful?

Solution

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 > 

OTHER TIPS

Try giving like this

<%= Time.now.utc.in_time_zone %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top