You are here

function xmlrpc_date in Drupal 7

Same name and namespace in other branches
  1. 4 includes/xmlrpc.inc \xmlrpc_date()
  2. 5 includes/xmlrpc.inc \xmlrpc_date()
  3. 6 includes/xmlrpc.inc \xmlrpc_date()

Converts a PHP or ISO date/time to an XML-RPC object.

Parameters

$time: A PHP timestamp or an ISO date-time string.

Return value

object An XML-RPC time/date object.

3 calls to xmlrpc_date()
XMLRPCValidator1IncTestCase::testValidator1 in modules/simpletest/tests/xmlrpc.test
Run validator1 tests.
xmlrpc_message_tag_close in includes/xmlrpc.inc
Handles closing tags for XML parsing in xmlrpc_message_parse().
xmlrpc_test_manyTypesTest in modules/simpletest/tests/xmlrpc_test.module

File

includes/xmlrpc.inc, line 492
Drupal XML-RPC library.

Code

function xmlrpc_date($time) {
  $xmlrpc_date = new stdClass();
  $xmlrpc_date->is_date = TRUE;

  // $time can be a PHP timestamp or an ISO one
  if (is_numeric($time)) {
    $xmlrpc_date->year = gmdate('Y', $time);
    $xmlrpc_date->month = gmdate('m', $time);
    $xmlrpc_date->day = gmdate('d', $time);
    $xmlrpc_date->hour = gmdate('H', $time);
    $xmlrpc_date->minute = gmdate('i', $time);
    $xmlrpc_date->second = gmdate('s', $time);
    $xmlrpc_date->iso8601 = gmdate('Ymd\\TH:i:s', $time);
  }
  else {
    $xmlrpc_date->iso8601 = $time;
    $time = str_replace(array(
      '-',
      ':',
    ), '', $time);
    $xmlrpc_date->year = substr($time, 0, 4);
    $xmlrpc_date->month = substr($time, 4, 2);
    $xmlrpc_date->day = substr($time, 6, 2);
    $xmlrpc_date->hour = substr($time, 9, 2);
    $xmlrpc_date->minute = substr($time, 11, 2);
    $xmlrpc_date->second = substr($time, 13, 2);
  }
  return $xmlrpc_date;
}