3

I am currently developing a page application which will allow users to schedule their page posts. As given in facebook documentation, I have to use unix time stamp ,but since the application is stored in a server it will always create a unix time stamp using mktime() respective of the server time.

Now suppose different people from different places need to schedule posts, how can i schedule their post for their given time??

Somnath Muluk
  • 55,015
  • 38
  • 216
  • 226
World Gamer
  • 333
  • 1
  • 4
  • 20
  • You may use the cron for this (using the extended token of the user) – Sahil Mittal Jan 04 '13 at 11:14
  • Find out their time zone/ask for it, and take it into account when creating the timestamp …? – CBroe Jan 04 '13 at 12:20
  • 1
    @CBroe sir,i have already set a timezone selector and have stored it in my session variable.Now my question is how will i generate the unix time stamp according to that time zone present time??? – World Gamer Jan 04 '13 at 13:19
  • 1
    @Sahil i know that,my question is how to send the particular time as parameter...the unix time stamp which shud represent the current user time. – World Gamer Jan 04 '13 at 13:20
  • You could use strtotime for example. – CBroe Jan 04 '13 at 13:24
  • 1
    @CBroe sir,can u please give me an example how can i use strtotime with my variable timezone?? – World Gamer Jan 04 '13 at 13:26

1 Answers1

0

You have to set a timezone for creating time-stamp.

$timezone= ''Americas/New_York';
$date = new DateTime($dateStr, new DateTimeZone($timezone));

or

date_default_timezone_set('Americas/New_York');
$date = strtotime($dateStr);

$attachment = array(
                'message' => $data['facebook_text'],
                'name' => $data['name'],
                'link' => $this->getLinkToLatestNews(),
                'description' => '',
                'scheduled_publish_time' => $date 
            );

$facebook->api('/PAGE ID/feed/', 'post', $attachment);

Note: Time when the page post should go live, this should be between 10 mins and 6 months from the time of publishing the post.

See:

  1. http://www.php.net/manual/en/function.date-default-timezone-set.php
  2. http://php.net/manual/en/datetime.construct.php
  3. Facebook Docs
Somnath Muluk
  • 55,015
  • 38
  • 216
  • 226