0

I have the following record on my data base:

"availability_date" : ISODate("2014-09-29T15:45:00.000Z")

and I trying to get the differences between two datetime like this:

@minutes = (((@date_time.to_time) - (Time.now))/60).round

but the @date_time have the following value and I don't understand why???

"2014-09-29 17:45:00 +0200"

could someone help me please.

Thanks in advance

Jean
  • 5,201
  • 11
  • 51
  • 87
  • Are you using MongoDB? Can you connect the code between availability_date and @date_time? I assume there is some missing code here. – Arthur Frankel Sep 29 '14 at 14:39

2 Answers2

1

I don't think there is any problem, The datetime in @date_time is the same as in your database. The +0200 at the end means that it is written in a different timezone, here GMT +2, I guess. It is probably the time zone that your computer uses.

What is the result you expect ? Can you give an example ? And be sure to read the answer to In Ruby on Rails, what's the difference between DateTime, Timestamp, Time and Date?

Good luck.

Community
  • 1
  • 1
Uelb
  • 3,947
  • 2
  • 21
  • 32
0

Try to convert them to integer using to_i m this give you the number of seconds in unix time, the n it's probably more easy to do a calculation

Geraud Mathe
  • 711
  • 2
  • 9
  • 20