- strnatcasecmp: documentation ( source)
<?php
class SerialDateTime extends DateTime implements JsonSerializable{
public function jsonSerialize(){
return ['timestamp' => $this->getTimestamp()];
}
public function __toString(){
return $this->getTimestamp();
}
// TODO: Is this the best way, or is there a better way?
public static function createFromFormat($f, $t, $tz=NULL){
$dateTime = call_user_func(
array('SerialDateTime', 'parent::createFromFormat'),
$f, $t, $tz
);
$ret = new self();
return $ret->setTimestamp($dateTime->getTimestamp());
}
}
echo strnatcasecmp(new SerialDateTime, new SerialDateTime('January 1, 2013'));