2

I have a date that I am storing as a timestamp through the formatDate function in jQuery. I am then retriving this value to make an ics file, a calender file that adds the event time and details to the users calender. However the timestamp format isn't working in the ics file, the correct date isn't being added, so I need to convert it to a value that looks like 20091109T101015Z. It's current format as a timestamp looks like 1344466800000This is from this example which is what I am following to create my ics file.

My link to the php file is http:// domain. com/icsCreator.php?startDate=1344380400000&endDate=1345503600000&event=Space%20Weather%20Workshop&location=London

Current my ics file looks like

<?php
$dtStart=$_GET['startDate'];
$dtEnd=$_GET['endDate'];
$eventName=$_GET['event'];
$location=$_GET['location'];

...
echo "CREATED:20091109T101015Z\n";
echo "DESCRIPTION:$eventName\n";
echo "DTEND:$dtEnd\n";    
echo "DTSTART:".$dtStart."\n";
echo "LAST-MODIFIED:20091109T101015Z\n";
echo "LOCATION:$location\n";
...

?>
4

2 に答える 2

6

これが機能するかどうかを確認します。

date('Ymd\THis', $time)

ここに、またはクエリ文字列からの$time可能性があります。時間が欲しくない場合:startDateendDate

date('Ymd', $time)

(Nicola に感謝) ここで$timeは、有効な UNIX タイムスタンプである必要があります。つまり、エポックからの秒数を表す必要があります。ミリ秒数を表す場合は、最初に 1000 で割る必要があります。

編集lars kで指摘されているよう\Zに、両方の文字列の末尾に追加する必要があります。

編集Nicolaが指摘したように、実際には必要ありません。

于 2012-08-03T10:32:55.900 に答える