I have been facing this problem where full calendar shows my event at a time 8 hours later than the event data.
I figured that it is due to my timezone.
This is my trace message
Started GET "/events?custom_param1=something&custom_param2=somethingelse& start=1351958400&end=1352563200& authenticity_token=XEXpcBRnQuEivJ2NWjR2+OZ+Uscypalxx+hqGTIiwZA=&_=1352086291522" for 127.0.0.1 at 2012-11-05 11:31:31 +0800
Processing by EventsController#index as JSON
Parameters: {"custom_param1"=>"something", "custom_param2"=>"somethingelse", "start"=>"1351958400", "end"=>"1352563200", "authenticity_token"=>"XEXpcBRnQuEivJ2NWjR2 OZ Uscypalxx hqGTIiwZA=", "_"=>"1352086291522"}
Event Load (0.5ms) SELECT `events`.* FROM `events` WHERE (starts_at > '2012-11-04T00:00:00+08:00') AND (ends_at < '2012-11-11T00:00:00+08:00')
Completed 200 OK in 10ms (Views: 8.2ms | ActiveRecord: 0.5ms)
The problem here being the start time in Unix is Sat, 03 Nov 2012 16:00:00 GMT when I had set it to be 04 Nov 2012 0.00.00.
Here are my codes
class Event < ActiveRecord::Base
scope :before, lambda {|end_time| {:conditions => ["ends_at < ?", Event.format_date(end_time)] }}
scope :after, lambda {|start_time| {:conditions => ["starts_at > ?", Event.format_date(start_time)] }}
def as_json(options = {})
{
:id => self.id,
:title => self.title,
:description => self.description || "",
:start => starts_at.rfc822,
:end => ends_at.rfc822,
:allDay => false,
:recurring => false,
:url => Rails.application.routes.url_helpers.event_path(id),
#:color => "red"
}
end
def self.format_date(date_time)
Time.at(date_time.to_i).to_time.iso8601
end
end
changing ignoreTimeZone to true didn’t work for me either.
So I would appreciate if someone could help me with it.
Maybe something along the lines of parsing time?
If you are passing a UNIX time value, it may be in seconds or milliseconds UTC from the epoch (1970-01-01T00:00:00Z). To get a local javascript date object set to the same time in the client’s local timezone, pass the UTC time value directly to the Date constructor.
e.g.
e.g.
To send back local times as UTC milliseconds since the epoch, do the reverse:
The time value returned by
getTimeis UTC milliseconds since epoch.