format('Y-m-d'); } parent::__construct($value, null, $datatype); } /** Parses a string using DateTime and creates a new literal * * Example: * $date = EasyRdf_Literal_Date::parse('1 January 2011'); * * @see DateTime * @param string $value The date to parse * @return object EasyRdf_Literal_Date */ public static function parse($value) { $value = new DateTime($value); return new EasyRdf_Literal_Date($value); } /** Returns the date as a PHP DateTime object * * @see DateTime::format * @return string */ public function getValue() { return new DateTime($this->value); } /** Returns date formatted according to given format * * @see DateTime::format * @param string $format * @return string */ public function format($format) { return $this->getValue()->format($format); } /** A full integer representation of the year, 4 digits * * @return integer */ public function year() { return (int)$this->format('Y'); } /** Integer representation of the month * * @return integer */ public function month() { return (int)$this->format('m'); } /** Integer representation of the day of the month * * @return integer */ public function day() { return (int)$this->format('d'); } }