aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/XMLRPCDateParameter.php
blob: 93bbbd8f549bb89959558c8ea7778bc43eb6b325 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
 * An ISO8601 data and time.
 *
 * @package    Elgg.Core
 * @subpackage XMLRPC
 */
class XMLRPCDateParameter extends XMLRPCParameter {
	/**
	 * Construct a date
	 *
	 * @param int $timestamp The unix timestamp, or blank for "now".
	 */
	function __construct($timestamp = 0) {
		parent::__construct();

		$this->value = $timestamp;

		if (!$timestamp) {
			$this->value = time();
		}
	}

	/**
	 * Convert to string
	 *
	 * @return string
	 */
	function __toString() {
		$value = date('c', $this->value);
		return "<value><dateTime.iso8601>{$value}</dateTime.iso8601></value>";
	}
}