Note that there are some explanatory texts on larger screens.

plurals
  1. POUnix Timestamp conversion for PHP Facebook event
    primarykey
    data
    text
    <p>I am using the Facebook PHP SDK to post events to a page on their behalf, but I'm having some problems with the <code>start_time</code> param as I'm pulling the date from a form field. From what I understand this param only accepts an ISO 8601 format date, so I did the following...</p> <p>The form field displays a date and time as follows (for example): <code>11/06/2013 08:00PM</code></p> <p>To which I convert it to a timestamp in Javascript by doing:</p> <pre><code>var d = new Date('11/06/2013 08:00PM'), eventTimestamp = d.getTime(); </code></pre> <p>Which spits out <code>1383796800000</code> - converted back this timestamp in human-readable format is <strong>Thu, 07 Nov 2013 04:00:00 GMT</strong> <em>(11/6/2013 8:00:00 PM GMT-8 in my timezone...)</em>. So far so good!</p> <p>Now here's where the problem comes in. I use POST to send this timestamp to my script posting the Facebook Event, and then to use it for the param I do this in PHP:</p> <p><code>date('c', $_POST['timestamp']);</code></p> <p>When I run the script the event that is posted comes out with a date of (as view on the Facebook Event page): <strong>Saturday, November 25, 1995</strong>.</p> <p>I hope I described this well enough. Can someone please help me out here?</p> <p><strong>Edit...</strong></p> <p>I displayed the data returned by the timestamp in the script, and something interesting happened. Maybe I'm just missing something, but when I echoed <code>$_POST['timestamp']</code> I got:</p> <p><code>1383796800000</code> (correct)</p> <p>But when I echoed <code>date('c', $_POST['timestamp'])</code> I got:</p> <p><code>1995-11-25T12:18:08-08:00</code> (very not correct)</p> <p>What am I missing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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