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 34
<?php
/**
* @type Date
* Catapult formatted
*
* represent a catipult
* style date
* Example:
* 2014-11-08T18:54:30Z
*
*/
namespace Catapult;
final class Date extends Types {
/**
* Input should allow datetime objects
* or unix stamps.
*/
public function __construct($datetime)
{
if (is_int($datetime)) {
$dt = new \DateTime();
$dt->setTimestamp($datetime);
} else {
$dt = $datetime;
}
$this->date = $dt;
}
public function __toString()
{
return $this->date->format(API::API_DATE_FORMAT);
}
}