1. <legend id='ekuj9'><style id='ekuj9'><dir id='ekuj9'><q id='ekuj9'></q></dir></style></legend>

      <small id='ekuj9'></small><noframes id='ekuj9'>

      <i id='ekuj9'><tr id='ekuj9'><dt id='ekuj9'><q id='ekuj9'><span id='ekuj9'><b id='ekuj9'><form id='ekuj9'><ins id='ekuj9'></ins><ul id='ekuj9'></ul><sub id='ekuj9'></sub></form><legend id='ekuj9'></legend><bdo id='ekuj9'><pre id='ekuj9'><center id='ekuj9'></center></pre></bdo></b><th id='ekuj9'></th></span></q></dt></tr></i><div id='ekuj9'><tfoot id='ekuj9'></tfoot><dl id='ekuj9'><fieldset id='ekuj9'></fieldset></dl></div>
      <tfoot id='ekuj9'></tfoot>

      • <bdo id='ekuj9'></bdo><ul id='ekuj9'></ul>

      谷歌日历 API 日期时间

      Google Calendar API date time(谷歌日历 API 日期时间)
        <tbody id='2038M'></tbody>

      <tfoot id='2038M'></tfoot>
        <bdo id='2038M'></bdo><ul id='2038M'></ul>
      • <legend id='2038M'><style id='2038M'><dir id='2038M'><q id='2038M'></q></dir></style></legend>
            • <small id='2038M'></small><noframes id='2038M'>

              <i id='2038M'><tr id='2038M'><dt id='2038M'><q id='2038M'><span id='2038M'><b id='2038M'><form id='2038M'><ins id='2038M'></ins><ul id='2038M'></ul><sub id='2038M'></sub></form><legend id='2038M'></legend><bdo id='2038M'><pre id='2038M'><center id='2038M'></center></pre></bdo></b><th id='2038M'></th></span></q></dt></tr></i><div id='2038M'><tfoot id='2038M'></tfoot><dl id='2038M'><fieldset id='2038M'></fieldset></dl></div>

                本文介绍了谷歌日历 API 日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试让 Google Calendar Api 正常工作.如果不使用我的 $_POST 日期时间,它就可以完美运行.但是然后日期像谷歌一样被硬编码,这不是我想要的.当我使用我的 $_POST 变量时,它向我显示了这个错误:

                I'm trying to get the Google Calendar Api to work. Without the use of my $_POST date times it works perfect. But then the date is hard coded like the google ones and that is not what i want. When i use my $_POST vars it shows me this error:

                Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling POST https://www.googleapis.com/calendar/v3/calendars/%40group.calendar.google.com/events?key=: (400) **Start and end times must either both be date or both be dateTime**.'
                

                我的日期时间代码:

                  if ($client->getAccessToken()){
                  $dt = new DateTime();
                  echo $dt->format("Y-m-dTH:i:s.000+01:00") . "
                ";
                
                  if (isset($_POST['addevent'])){
                  echo "<hr><font size=+1>I have access to your calendar</font>";
                  $event = new Google_Service_Calendar_Event();
                  $event->setSummary($_POST['title']);
                  $event->setLocation($_POST['location']);
                  $start = new Google_Service_Calendar_EventDateTime();
                  $start->setTimeZone('Europe/Amsterdam');
                  $start->setDateTime($dt);
                  $event->setStart($start);
                  $end = new Google_Service_Calendar_EventDateTime();
                  $end->setDateTime($dt);
                  $event->setEnd($end);
                  $createdEvent = $cal->events->insert('f8ov32gchvan0b6a0594r72jng@group.calendar.google.com', $event);
                  echo "<br><font size=+1>Event created</font>";
                
                  echo "<hr><br><font size=+1>Already connected</font> (No need to login)";
                
                  }
                

                我也在试验 echo $dt->format("c") ." ";这只是在没有 .000 的情况下给了我同样的东西.Google 日历要求我使用一角钱的时间格式,例如:

                I'm also experimenting with echo $dt->format("c") . " "; which is giving me the same thing only without .000 . Google Calendar requires me to have a dime time format like:

                $start->setDateTime('2012-10-31T10:00:00.000-05:00');
                $event->setStart($start);
                $end = new Google_EventDateTime();
                $end->setDateTime('2012-10-31T10:25:00.000-05:00');
                $event->setEnd($end);
                

                来源:用 PHP 创建简单的 Google 日历事件

                我的 HTML 输入字段:

                My HTML input fields:

                <input type="datetime-local" name="date1">Date1<br>
                <input type="datetime-local" name="date2">Date2<br>
                

                ATM 我没有使用我的 $_POST 我正在检查

                ATM i'm not using my $_POST i'm checking with

                $dt = new DateTime();
                echo $dt->format("Y-m-dTH:i:s.000+01:00") . "
                ";
                

                所以我的问题是,我如何使用 PHP 获得谷歌时间格式?

                So my question is, How do i get the google time format with PHP?

                谢谢

                推荐答案

                查看 Google 日历 API 文档 所需格式必须遵循 RFC 3339 格式.要将 DateTime 转换为这种格式,可以使用 DateTime::format 函数与 DateTime::RFC3339 常量.

                Looking at the Google Calendar API docs the required format must follow the RFC 3339 format. To convert a DateTime to this format one can use the DateTime::format function in conjunction with the DateTime::RFC3339 constant.

                你应该得到类似的东西:

                You should get something like:

                $dt = new DateTime();
                $calendarDateTime = new Google_Service_Calendar_EventDateTime();
                $calendarDateTime->setDateTime($dt->format(DateTime::RFC3339));
                

                这篇关于谷歌日历 API 日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                      <tbody id='HKdrk'></tbody>

                    <small id='HKdrk'></small><noframes id='HKdrk'>

                      1. <legend id='HKdrk'><style id='HKdrk'><dir id='HKdrk'><q id='HKdrk'></q></dir></style></legend>

                      2. <i id='HKdrk'><tr id='HKdrk'><dt id='HKdrk'><q id='HKdrk'><span id='HKdrk'><b id='HKdrk'><form id='HKdrk'><ins id='HKdrk'></ins><ul id='HKdrk'></ul><sub id='HKdrk'></sub></form><legend id='HKdrk'></legend><bdo id='HKdrk'><pre id='HKdrk'><center id='HKdrk'></center></pre></bdo></b><th id='HKdrk'></th></span></q></dt></tr></i><div id='HKdrk'><tfoot id='HKdrk'></tfoot><dl id='HKdrk'><fieldset id='HKdrk'></fieldset></dl></div>
                        <tfoot id='HKdrk'></tfoot>

                        • <bdo id='HKdrk'></bdo><ul id='HKdrk'></ul>