저는 Google Calendar API 용 Zend Framework Gdata와 RFC3339 (2012-01-19T22 : 00 : 00.000-08 : 00처럼 보입니다)의 datetime 출력을 사용하고 있습니다. UTC로 변환하기 위해 추가해야하는 PHP 코드는 다음과 같습니다. 2012 년 1 월 19 일 오후 8시 - 오후 11시? RFC 날짜를 문자열로 변환하는 PHP 코드를 발견했지만 Zend Gdata 수식을 사용하여 코드를 변경할 수있는 PHP에 대해 충분히 알지 못합니다. 아래 코드에서 볼 수 있듯이 "date "라고하면"언제 "... 모든 코드가 그 두 가지를 어떻게 든 연결해야합니다 ... 어떤 도움을 주셔서 감사합니다! Zend Google 캘린더 API - DateTime 형식을 변경하는 방법
<?php
$path = '/home/ZendGdata/library';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
// User whose calendars you want to access
$user = '[email protected]';
$pass = 'mypassword';
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name for calendar
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Calendar($client);
$query = $service->newEventQuery();
// Set different query parameters
$query->setUser('mycalendarID');
$query->setVisibility('private');
$query->setProjection('full');
$query->setOrderby('starttime');
// Start date from where to get the events
$query->setStartMin('2012-01-01');
// End date
$query->setStartMax('2050-03-15');
// Get the event list
try {
$eventFeed = $service->getCalendarEventFeed($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
echo "<ul>";
foreach ($eventFeed as $event) {
echo "<tr>";
foreach ($event->when as $when) {
echo "<td>" . $when->startTime . "</td>";
}
echo "<td>" . $event->content . " </td>";
$where=$event->Where;
foreach($where as $eventplace)
{
echo "<td>" . $eventplace . " </td>";
}
}
echo "</tr>";
echo "</ul>";
?>
이 정보를 @vascowhite 주셔서 감사합니다.
두 가지 문제가 :
출력은 다음과 같이 밝혀졌다 : 문자열 (23) "2012 1월 20일 : 6시"
- 내 구글 캘린더에서이 정보를 당겨하고
, 그리고 그것은 내 HTML 페이지로 출력하고있다 ... 나는이 PHP를 통해 새로운 이벤트를 생성하지 않는다 ... 그래서이 코드는 단순히 당신이 쓴 날짜를 변환, 그것은 내 Google 캘린더 이벤트 날짜를 뽑아이 변환하지 않았다 코드 :
foreach ($event->when as $when) { echo "<td>" . $when->startTime . "</td>"; }
어떻게하는 지 알고 계십니까?
당신은 아주 쉽게이 작업을 수행하기 위해 PHP의 DateTime 클래스를 사용할 수 있습니다, 감사 수잔
왜 tr & td 목록에있어? 캘린더는 어떤 시간대에 있습니까? – vascowhite