事件(作为json提要),启动结束参数unix timestamp,如果我更改操作系统时区,则会有所不同 [英] events (as a json feed), start end parameters unix timestamp, are different if I change my OS time zone

查看:108
本文介绍了事件(作为json提要),启动结束参数unix timestamp,如果我更改操作系统时区,则会有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用fullcalendar插件,并希望有人能帮我一把。



我通过PHP URL获取json事件。
这样的东西:

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

所以在我的php页面返回事件,我得到3个GET参数:




  • '_'

  • '开始'

  • 'end'



开始和结束参数指示UNIX时间戳记中的日期。
到目前为止,发生的问题是,如果我在我的操作系统上更改时区。也可以在日历中的同一天更改这些参数的开始和结束。
最奇怪的部分是它只发生在Mozilla Firefox中。
在谷歌浏览器中,这个问题不会发生。



eg



我设定了我的时间((UTC-04:00)圣地亚哥)
我指的是09.09.2012在日程上的日子,
firebug向我显示这些参数正在发送到我的php页面




  • _ 1347245953581

  • 结束1347246000

  • 开始1347159600



  • 但是如果我将操作系统的时区更改为((UTC-03:00)布宜诺斯艾利斯)
    咨询09.09.2012在议程中,
    是现在发送到PHP页面的其他参数。


    • _ 1347246338047

    • end 1347332400

    • 开始1347246000



    因为这是同一天,是发送的其他开始和结束参数以检查事件。

    解决方案

    在fullcalendar上有一个ignoreTimezone选项可能会帮帮我。我不确定它是否会影响传递到Feed的开始/结束时间。



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

    另一个选项是将传递的时间戳转换为Date对象,然后从Date对象中获取本地数据,并在查询中使用该数据。 将JavaScript时间戳转换为JavaScript中的时间



    我知道这不是确切的答案,但它可能会帮助你一点。



    以下是一段PHP代码示例,用于将传递的时间戳转换为本地格式化日期:

      $ startts = $ _REQUEST [start]; //原始时间戳

    $ startdt = new DateTime('now',new DateTimeZone('Europe / Oslo')); //设置本地日期时间
    $ startdt-> setTimestamp($ startts); //根据时间戳设置日期

    echo $ startdt->格式('Y-m-d H:i:s'); //输出本地日期和时间


    I'm using the fullcalendar plugin and would appreciate if someone can give me a hand.

    I am getting json events through a PHP URL. something like this:

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

    So in my php page that returns the events, I am getting 3 GET parameters:

    • '_'
    • 'start'
    • 'end'

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

    e.g.

    I have set my time zone ((UTC-04: 00) Santiago) I'm referring to the day 09.09.2012 on the agenda, firebug shows me that these parameters are being 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, are other parameters which are now sent to the PHP page.

    • _ 1347246338047
    • end 1347332400
    • start 1347246000

    Being that it is the same day, are other start and end parameters which are sent to check for events.

    解决方案

    There is an ignoreTimezone option on the fullcalendar that might help. I'm not sure if it affects the start/end time passed to the feeds.

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

    Another option is to convert the passed timestamp to a Date object and get the local data from the Date object afterwards and use that in your queries.

    Convert a Unix timestamp to time in JavaScript

    I know it is not the exact answer, but it might help you out a bit.

    Here is a sample piece of PHP code to convert the passed timestamp into 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('Y-m-d H:i:s'); // Output local date and time
    

    这篇关于事件(作为json提要),启动结束参数unix timestamp,如果我更改操作系统时区,则会有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆