I am using the Facebook PHP SDK to post events to a page on their behalf, but I'm having some problems with the start_time
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...
The form field displays a date and time as follows (for example): 11/06/2013 08:00PM
To which I convert it to a timestamp in Javascript by doing:
var d = new Date('11/06/2013 08:00PM'),
eventTimestamp = d.getTime();
Which spits out 1383796800000
- converted back this timestamp in human-readable format is Thu, 07 Nov 2013 04:00:00 GMT (11/6/2013 8:00:00 PM GMT-8 in my timezone...). So far so good!
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:
date('c', $_POST['timestamp']);
When I run the script the event that is posted comes out with a date of (as view on the Facebook Event page): Saturday, November 25, 1995.
I hope I described this well enough. Can someone please help me out here?
Edit...
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 $_POST['timestamp']
I got:
1383796800000
(correct)
But when I echoed date('c', $_POST['timestamp'])
I got:
1995-11-25T12:18:08-08:00
(very not correct)
What am I missing?