dououde4065 2014-02-18 07:36
浏览 196
已采纳

PHP中的ISO日期时间

I have an ISO DATETIME format parsed from web calendar ICS files. I have created calendar event in google and yahoo. In google, I have created for the time of 11:00 to 11:30 IST. In yahoo, I have created for the time of 11:30 to 11:45 IST.

I have received ICS files for both the events. My problem is with the event start time and end time in the ICS files.

Google Start time - 20140218T060000Z (provides GMT time)

Yahoo Start time - 20140218T113000Z (provides local time)

How can I check if the timezone in the ISO datetime is GMT and convert it to GMT if not? Please help me to achieve this. Thanks in advance.

  • 写回答

3条回答 默认 最新

  • duanque3125 2014-02-18 08:05
    关注

    There should be a timezone declaration in the ical file you can use.

    The RFC places this on the DTSTART, for example:

    DTSTART;TZID=America/New_York:19980119T020000
    

    But ical is not a very exact "science", it seems like everybody uses it different. I've seen timezone declarations like this:

    X-WR-TIMEZONE:Europe/Berlin
    

    which only show up once in the ical file.

    After creating a DateTime object you can use DateTime::setTimezone to set it. Example from the PHP documentation:

    $date = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru'));
    echo $date->format('Y-m-d H:i:sP') . "
    ";
    
    $date->setTimezone(new DateTimeZone('Pacific/Chatham'));
    echo $date->format('Y-m-d H:i:sP') . "
    ";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来