Events (like json channel), the initial end parameters of unix timestamp, are different if I change the time zone of my OS

I am using the fullcalendar plugin and would appreciate it if someone could give me a hand.

I get json events via PHP url. something like that:

$('#calendar').fullCalendar({ events: "/myfeed.php" }); 

So, on my php page that returns events, I get 3 GET parameters:

  • '_'
  • 'to begin'
  • 'end'

The start and end parameters indicate the date in the UNIX timestamp. So far so good, the problem is: if I change the time zone on my OS. also change these parameters to the beginning and the end, for the same request on the same day in the calendar. the strangest part is that this only happens in Mozilla Firefox. In Google Chrome, this problem does not occur.

eg.

I set my time zone ((UTC-04: 00) Santiago) I mean the day 09.09.2012 on the agenda, firebug shows me that these parameters are sent to my php page

  • _ 1347245953581
  • end 1347246000
  • start 1347159600

but if I change the time zone from my OS to ((UTC-03: 00) Buenos Aires) consulting on 09.09.2012 on the agenda, other parameters that are now sent to the PHP page.

  • _ 1347246338047
  • end 1347332400
  • start 1347246000

Since this is the same day, these are other start and end parameters that are sent to check for events.

+4
source share
1 answer

Fullcalendar has an ignoreTimezone option that can help. I am not sure if this affects the start and end time of transmission to the channels.

http://arshaw.com/fullcalendar/docs/event_data/ignoreTimezone/

Another option is to convert the past timestamp to a Date object and then get the local data from the Date object and use it in your queries.

Convert Unix timestamp to JavaScript

I know this is not an exact answer, but it may help you a little.

Here is an example PHP code snippet for converting the past timestamp to a local formatted date:

 $startts = $_REQUEST["start"]; // original timestamp $startdt = new DateTime('now', new DateTimeZone('Europe/Oslo') ); // setup a local datetime $startdt->setTimestamp($startts); // Set the date based on timestamp echo $startdt->format('Ymd H:i:s'); // Output local date and time 
0
source

Source: https://habr.com/ru/post/1433282/


All Articles