title: Datetime format Rails
body: <p>I am having problem understanding datetime format in rails. I have stored a date which is called 'starts_at' and type is datetime using postman. </p>
  
  <pre><code>{
      "reservation": {
          "starts_at": "2020-1-7 7:00 pm",
          "expires_at": "2020-1-7 9:00 pm"
      }
  }
  </code></pre>
  
  <p>I want to enter another date and want to validate the date I enter every time be in an interval of 120 minutes after.
  So I tried plucking out 'starts_at' from my model 'reservations' and tried to loop through each 'starts_at' date and comparing their difference with my new entered dates' 'starts_at'.</p>
  
  <pre><code># I have defined scope to pluck the 'starts_at' in reservation.rb
  # scope :starts_at, -&gt; { pluck(:starts_at) }
  
  def create
     Reservation.starts_at.each do |starts_at|
          time_diffs = time_diff_in_minutes(date_time_conversion(starts_at) - params[:starts_at].to_datetime)
          if time_diffs &lt; 120
            return
          end
          @reservation = Reservation.new(processed_params)
          reservation.save
        end
     end
  
  
    private
  
    def date_time_conversion(starts_at)
      starts_at.to_datetime
    end
  
    def time_diff_in_minutes(time_calc)
      (time_calc * 24 * 60).to_s.to_i.abs
    end
  </code></pre>
  
  <p>I have one value in database which has starts_at datetime = "2020-1-7 7:00 pm".
  When I run debugger and checked the plucked value it has a format something like </p>
  
  <pre><code>Tue, 07 Jan 2020 18:00:00 +06 +06:00
  </code></pre>
  
  <p>And the format of the date I entered was something like</p>
  
  <pre><code> Tue, 07 Jan 2020 19:00:00 +0000
  </code></pre>
  
  <p>I want to understand what does +06 +6:00 means and how does postgresql database store datetime object and return format. Your help shall be highly appreciated. Thank you!</p>