Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP: Facebook Event API start_time doesn't show today's events
    text
    copied!<p>I'm fetching Facebook events to my site but have problem that today's events disappear one day to early. If there is an event today it will not show on my site, today. At 00:00 today the event disappears from the view.</p> <p><strong>I use the code below:</strong></p> <pre><code>&lt;?php //we have to set timezone to California date_default_timezone_set('California'); //requiring FB PHP SDK require 'fb-sdk/src/facebook.php'; //initializing keys $facebook = new Facebook(array( 'appId' =&gt; 'APP_ID', 'secret' =&gt; 'APP_SECRET', 'cookie' =&gt; true, // enable optional cookie support )); $fql = "SELECT eid, name, pic, start_time, end_time, location, description, attending_count FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = PAGE_ID) AND start_time &gt;= now() ORDER BY start_time ASC"; $param = array( 'method' =&gt; 'fql.query', 'query' =&gt; $fql, 'callback' =&gt; '' ); $fqlResult = $facebook-&gt;api($param); //looping through retrieved data foreach( $fqlResult as $keys =&gt; $values ) { $start_date = date( 'l, F d, Y', $values['start_time'] ); $end_date = date( 'l, F d, Y', $values['end_time'] ); $start_time = date( 'g:i a', $values['start_time'] ); $end_time = date( 'g:i a', $values['end_time'] ); $time = explode("T", $values['start_time']); $tid = explode("+", $time[1]); if ($time[0] &gt; date("Y-m-d")) { //printing the data echo "&lt;div class='event'&gt;"; echo "&lt;div&gt;"; echo "&lt;table&gt;&lt;tr&gt;&lt;td valign='top'&gt;"; echo "&lt;img src={$values['pic']} width='100px' /&gt;"; echo "&lt;/td&gt;&lt;td valign='top'&gt;"; echo "&lt;span style='font-family:verdana;font-size:10pt;'&gt;&lt;b&gt;" . $values['name'] . "&lt;/b&gt;&lt;/span&gt;&lt;br&gt;"; echo "&lt;span style='font-family:verdana;font-size:9pt; color:#666666; line-height:7pt;'&gt;".$time[0]." kl ".substr($tid[0],0,5)."&lt;br&gt;"; echo "Place: " . $values['location'] . "&lt;br&gt;".$values['attending_count']. " attendings.&lt;br&gt;"; echo "&lt;a href='https://www.facebook.com/events/".$values['eid']."/' target='_blank'&gt;&lt;br&gt;More info&lt;/a&gt;&lt;/span&gt;"; echo "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;"; echo "&lt;/div&gt;"; echo "&lt;/div&gt;"; } } ?&gt; </code></pre> <p><code>date_default_timezone_set('America/Los_Angeles');</code> doesn't work.</p> <p>Does anyone knows why? Thanks in advance.</p> <p><strong>UPDATE -> SOLUTION</strong></p> <p>Change <code>if ($time[0] &gt; date("Y-m-d"))</code> to <code>if ($time[0] &gt;= date("Y-m-d"))</code> and it will display events from today.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload