1. Date functions

The XML-RPC specification has this to say on dates:

Don't assume a timezone. It should be specified by the server in its documentation what assumptions it makes about timezones.

Unfortunately, this means that date processing isn't straightforward. Although XML-RPC uses ISO 8601 format dates, it doesn't use the timezone specifier.

We strongly recommend that in every case where you pass dates in XML-RPC calls, you use UTC (GMT) as your timezone. Most computer languages include routines for handling GMT times natively, and you won't have to translate between timezones.

For more information about dates, see ISO 8601: The Right Format for Dates, which has a handy link to a PDF of the ISO 8601 specification. Note that XML-RPC uses exactly one of the available representations: CCYYMMDDTHH:MM:SS.

1.1. iso8601_encode

$isoString = iso8601_encode($time_t, $utc=0);
$time_t;
$utc=0;

Returns an ISO 8601 formatted date generated from the UNIX timestamp $time_t, as returned by the PHP function time().

The argument $utc can be omitted, in which case it defaults to 0. If it is set to 1, then the function corrects the time passed in for UTC. Example: if you're in the GMT-6:00 timezone and set $utc, you will receive a date representation six hours ahead of your local time.

The included demo program vardemo.php includes a demonstration of this function.

1.2. iso8601_decode

$time_t = iso8601_decode($isoString$utc=0); 
 $isoString$utc=0 ;

Returns a UNIX timestamp from an ISO 8601 encoded time and date string passed in. If $utc is 1 then $isoString is assumed to be in the UTC timezone, and thus the $time_t result is also UTC: otherwise, the timezone is assumed to be your local timezone and you receive a local timestamp.