GoogleCalendarAPIにZendFrameworkGdataを使用しており、RFC3339の日時出力(2012-01-19T22:00:00.000-08:00のようになります)を使用しています。これをUTCに変換して、2012年1月19日午後8時から午後11時のようにするには、どのphpコードを追加する必要がありますか?RFCの日付を文字列に変換するphpコードを見つけましたが、Zend Gdata式で動作するようにコードを変更できるようにするためのphpについて十分な知識がありません...以下のコードでわかるように、「date 「」は「いつ」と呼ばれます...したがって、コードはこれら2つを何らかの方法で接続する必要があります...助けていただければ幸いです。
<?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 = 'my@email.com';
$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。
2つの問題:
出力は次のようになりました:string(23) "2012年1月20日:06:00"
私はグーグルカレンダーからこの情報を引き出しています、そしてそれは私のhtmlページに出力しています...私はこのphpを通して新しいイベントを作成していません...それでこのコードはあなたが書いた日付を単に変換しました、それは変換しませんでしたこのコードから取得した私のグーグルカレンダーイベントの日付:
foreach ($event->when as $when) {
echo "<td>" . $when->startTime . "</td>";
}
あなたはそれをする方法を知っていますか?
ありがとう、スーザン