How do I pass a date/time from PHP to CloudKit?

I have a php script that communicates with a CloudKit database. I am trying to pass a date and time from the PHP script to a CK database that has Date/Time fields.


I am getting this error from CloudKit "Invalid value, expected type TIMESTAMP"


I've searched a bunch for how to do this and find nothing helpful and I've tried a number of different ways to format the time with php.

I should I be formatting the time to get CloudKit to accept the data?

Replies

OK, after finding time to work on this issue a little more . . .


I had failed to notice that CloudKit returns dates as a 13-digit TIMESTAMP, that is, in microseconds. So, in php, the following code makes a correct human-readable date, to wit:


$timestamp = $record['created']['timestamp'];  // From CK
$timestamp = $timestamp/1000;
echo '<td>'.date('m-d-Y H:i:s', $timestamp)."</td>";


outputs 04-28-2017 12:35:19. Fine and dandy.


So I would ASSUME that if CK outputs dates as a 13-digit TIMESTAMP, it should accept the same when passed to a CK DateTime field, but passing such results in the error:


"Invalid value, expected type TIMESTAMP"


So is there really no way to pass a date to CK via CK web services? Really?


Again the documentation is vauge on this point. I note the error does not say "expected type NSDate".

What did you find out about this? Is it correct that there is no way to pass a date?

As you said, you must send microseconds (13 digits). So something like this:


(new DateTime())->getTimestamp() * 1000;


please be sure, that you send timestamp as integer and not string!