Source for file dateTime.php
Documentation is available at dateTime.php
* This file contains the code for the SOAP_Type_dateTime class.
* LICENSE: This source file is subject to version 2.02 of the PHP license,
* that is bundled with this package in the file LICENSE, and is available at
* through the world-wide-web at http://www.php.net/license/2_02.txt. If you
* did not receive a copy of the PHP license and are unable to obtain it
* through the world-wide-web, please send a note to license@php.net so we can
* mail you a copy immediately.
* @author Dietrich Ayala <dietrich@ganx4.com> Original Author
* @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more
* @author Jan Schneider <jan@horde.org> Maintenance
* @copyright 2003-2007 The PHP Group
* @license http://www.php.net/license/2_02.txt PHP License 2.02
* @link http://pear.php.net/package/SOAP
* This class converts from and to unix timestamps and ISO 8601 date/time.
* @author Dietrich Ayala <dietrich@ganx4.com> Original Author
* @author Shane Caraveo <shane@php.net> Port to PEAR and more
* @author Jan Schneider <jan@horde.org> Maintenance
'# 1: centuries & years CCYY-
# 8: Z to indicate UTC, -+HH:MM:SS.SS... for local zones
(Z|[+\-][0-9]{4}|[+\-][0-9]{2}:[0-9]{2})?';
* @param string|integer$date The timestamp or ISO 8601 formatted
* date and time this object is going to
* Alias of {@link SOAP_Type_dateTime::toUTC}.
return $this->toUTC($date);
* Converts this object or a timestamp to an ISO 8601 date/time string.
* @param integer $timestamp A unix timestamp
* @return string An ISO 8601 formatted date/time string.
//simulate PHP5's P parameter
$zone = date('O', $timestamp);
return date('Y-m-d\TH:i:s', $timestamp) . $zone;
* Splits a date/time into its components.
* @param string|integer$datestr A unix timestamp or ISO 8601 date/time
* string. If empty, this object is used.
* @return boolean|array An array with the date and time components or
function _split ($datestr)
if (preg_match('/' . $this->_iso8601 . '/x', $datestr, $regs)) {
$regs[8 ] = date('O', $timestamp);
$regs[4 ] = $regs[4 ] - $h;
$regs[5 ] = $regs[5 ] - $m;
$regs[4 ] = $regs[4 ] + $h;
$regs[5 ] = $regs[5 ] + $m;
* Returns an ISO 8601 formatted UTC date/time string.
* @param string|integer$datestr @see SOAP_Type_dateTime::_split
* @return string The ISO 8601 formatted UTC date/time string.
function toUTC($datestr = null )
$regs = $this->_split ($datestr);
return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',
* Returns a unix timestamp.
* @param string|integer$datestr @see SOAP_Type_dateTime::_split
* @return integer The unix timestamp.
$regs = $this->_split ($datestr);
* Compares two dates or this object with a second date.
* @param string|integer$date1 A unix timestamp or ISO 8601 date/time
* @param string|integer$date2 A unix timestamp or ISO 8601 date/time
* string. If empty, this object is used.
* @return integer The difference between the first and the second date.
function compare($date1, $date2 = null )
if ($date1 != -1 && $date2 != -1 ) {
Documentation generated on Mon, 04 Aug 2008 20:00:15 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|