You are here

function timestamp_to_iso8601 in Salesforce Suite 5.2

Same name in this branch
  1. 5.2 includes/nusoap.php \timestamp_to_iso8601()
  2. 5.2 includes/nusoap.orig.php \timestamp_to_iso8601()
Same name and namespace in other branches
  1. 5 includes/nusoap.php \timestamp_to_iso8601()
  2. 5 includes/nusoap.orig.php \timestamp_to_iso8601()

convert unix timestamp to ISO 8601 compliant date string

@access public

Parameters

string $timestamp Unix time stamp:

File

includes/nusoap.php, line 829

Code

function timestamp_to_iso8601($timestamp, $utc = true) {
  $datestr = date('Y-m-d\\TH:i:sO', $timestamp);
  if ($utc) {
    $eregStr = '([0-9]{4})-' . '([0-9]{2})-' . '([0-9]{2})' . 'T' . '([0-9]{2}):' . '([0-9]{2}):' . '([0-9]{2})(\\.[0-9]*)?' . '(Z|[+\\-][0-9]{2}:?[0-9]{2})?';

    // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
    if (ereg($eregStr, $datestr, $regs)) {
      return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ', $regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6]);
    }
    return false;
  }
  else {
    return $datestr;
  }
}