Skip to content

Commit 848728d

Browse files
committed
Merge pull request #47 from iamfrankhe/master
Fix datetime format used in Local Push Scheduling. Scheduling does not w...
2 parents b464ab3 + 021ae94 commit 848728d

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/Parse/ParseClient.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,20 @@ public static function getProperDateFormat($value)
357357
return $date;
358358
}
359359

360+
/**
361+
* Get a date value in the format to use in Local Push Scheduling on Parse.
362+
*
363+
* All the SDKs do some slightly different date handling.
364+
* Format from Parse doc: an ISO 8601 date without a time zone, i.e. 2014-10-16T12:00:00 .
365+
*
366+
* @param \DateTime $value DateTime value to format.
367+
*
368+
* @return string
369+
*/
370+
public static function getLocalPushDateFormat($value)
371+
{
372+
$dateFormatString = 'Y-m-d\TH:i:s';
373+
$date = date_format($value, $dateFormatString);
374+
return $date;
375+
}
360376
}

src/Parse/ParsePush.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public static function send($data, $useMasterKey = false)
4747
}
4848
}
4949
if (isset($data['push_time'])) {
50-
$data['push_time'] = ParseClient::_encode(
51-
$data['push_time'], false
52-
)['iso'];
50+
//Local push date format is different from iso format generally used in Parse
51+
//Schedule does not work if date format not correct
52+
$data['push_time'] = ParseClient::getLocalPushDateFormat($data['push_time']);
5353
}
5454
if (isset($data['expiration_time'])) {
5555
$data['expiration_time'] = ParseClient::_encode(

0 commit comments

Comments
 (0)