获取ACF时间和日期戳到谷歌日历

时间:2015-12-19 11:43:35

标签: php wordpress advanced-custom-fields

我正在尝试创建一个链接,使用日期和时间选择器字段插件从高级自定义字段向Google日历添加日期,但我认为我将自己捆绑在一起。

到目前为止,这就是我所在的地方

<?php 
$format = "Ymd\THis\Z";
$starttime = get_field('start');
$endtime = get_field('end');
$eventstart = date($format , $starttime);
$eventend = date($format , $endtime);?>

<a href="http://www.google.com/calendar/event?
action=TEMPLATE
&text=[<?php the_title(); ?>]
&dates=[start-custom format='<?php echo $eventstart ;?>']/
[end-custom format='<?php echo $eventend ;?>']
&details=[<?php echo (get_field('summary'));?>]
&location=[address]
&trp=false
&sprop=
&sprop=name:"
target="_blank" rel="nofollow">Add to my calendar</a>

$eventstart$eventend返回看似有效的格式(20151231T120000Z&amp; 20151231T140000Z分别)但是当链接到谷歌日历时,它只是在今天的日期加载谷歌日历与你的

    https://calendar.google.com/calendar/render?action=TEMPLATE&text=[test+event]&dates=[start-custom+format%3D%2720151231T120000Z%27]/[end-custom+format%3D%2720151231T140000Z%27]&details=[]&location=[location]&trp=false&sprop&sprop=name:&pli=1&sf=true&output=xml#main_7

谁能告诉我哪里可能出错?

1 个答案:

答案 0 :(得分:0)

我是一个完全白痴!正确地在链接中编写代码可以修复它:

<a href="http://www.google.com/calendar/event?
action=TEMPLATE
&text=<?php the_title(); ?>
&dates=<?php echo $eventstart ;?>/<?php echo $eventend ;?>
&details=<?php echo (get_field('summary'));?>
&location=<?php echo (get_field('address'));?>"
target="_blank" rel="nofollow">Add to my calendar</a>