php - CalendarView 只获取今天的事件
问题描述
我正在使用 PHP 中的图表,并为应该只提取今天的事件(包括全天事件)的站点构建日历小部件。
一切正常,但它也会拉动昨天的全天事件,我无法弄清楚我做错了什么。
$today = new DateTime( 'now', new DateTimeZone( 'America/New_York' ) );
$tomorrow = new DateTime( 'tomorrow', new DateTimeZone( 'America/New_York' ) );
$start_date = $today->format('Y-m-d');
$end_date = $tomorrow->format('Y-m-d');
$events = ms_get_data_as_json( 'calendarview?startdatetime=' . $start_date . '&enddatetime=' . $end_date . '&$orderby=start/DateTime' );
格式化的请求字符串输出calendarview?startdatetime=2018-05-18&enddatetime=2018-05-19&$orderby=start/DateTime
看起来可以正常工作,但是发送此请求,返回的第一个对象是前一天的全天事件。查看示例输出:
[0] => stdClass Object
(
[createdDateTime] => 2018-05-18T13:30:37.8672462Z
[lastModifiedDateTime] => 2018-05-18T13:34:25.2248155Z
[categories] => Array
(
)
[originalStartTimeZone] => UTC
[originalEndTimeZone] => UTC
[reminderMinutesBeforeStart] => 1080
[isReminderOn] =>
[hasAttachments] =>
[subject] => Test yesterday
[bodyPreview] =>
[importance] => normal
[sensitivity] => normal
[isAllDay] => 1
[isCancelled] =>
[isOrganizer] => 1
[responseRequested] => 1
[seriesMasterId] =>
[showAs] => free
[type] => singleInstance
[onlineMeetingUrl] =>
[recurrence] =>
[responseStatus] => stdClass Object
(
[response] => organizer
[time] => 0001-01-01T00:00:00Z
)
[body] => stdClass Object
(
[contentType] => html
[content] =>
)
[start] => stdClass Object
(
[dateTime] => 2018-05-17T00:00:00.0000000
[timeZone] => UTC
)
[end] => stdClass Object
(
[dateTime] => 2018-05-18T00:00:00.0000000
[timeZone] => UTC
)
)
起始属性显然是针对前一个日期的。
我试图更改我的查询以包含时间戳startdatetime=2018-05-18T00:00:01Z&enddatetime=2018-05-18T23:59:59Z
,但我仍然得到相同的结果。我尝试将我的$today
和$tomorrow
变量更改为使用 UTC,因为返回的结果显示OriginalStartTimeZone
为 UTC,但我仍然得到相同的结果。
任何帮助表示赞赏。
解决方案
我认为应用开始/结束日期过滤器的方式存在一些不平等问题,它最终包括在开始时间结束(或在结束时间开始)的事件。
目前,似乎解决方案是在过滤器的开始时间上增加 1 秒,从过滤器的结束时间中减去 1 秒。您仍会收到请求日期的全天事件,但不会收到前一天或第二天的全天事件。
如果您发现不适用于此方法的情况,请告诉我们!
推荐阅读
- python - 按值降序然后键降序对字典进行排序
- jquery - 检查何时按下 Enter 键
- pyspark - Pyspark 错误:py4j.java_gateway:尝试连接到 Java 服务器时发生错误(127.0.0.1:50532)
- visual-studio - 在 Visual Studio 中集成 Crashlytics?
- python - AttributeError:“张量”对象在实施共同注意层期间没有属性“_keras_history”
- javascript - javascript:window.location 自动更改包含的链接
- jquery - 错误类型错误:e.addClass 不是函数
- python - 根据另一个列表的排序方式对列表进行排序
- php - 用户签名后docusign下载文件
- ios - 如何更改 webview 中属性字符串的字体大小?