class MyFeatureContext extends BehatContext {
protected $dateFormat = 'Y-m-d';
/**
* Transforms relative date statements compatible with strtotime().
* Example: "date 2 days ago" might return "2013-10-10" if its currently
* the 12th of October 2013. Customize through {@link setDateFormat()}.
*
* @Transform /^(?:(the|a)) date of (?.*)$/
*/
public function castRelativeToAbsoluteDate($prefix, $val) {
$timestamp = strtotime($val);
if(!$timestamp) {
throw new \InvalidArgumentException(sprintf(
"Can't resolve '%s' into a valid datetime value",
$val
));
}
return date($this->dateFormat, $timestamp);
}
public function getDateFormat() {
return $this->dateFormat;
}
public function setDateFormat($format) {
$this->dateFormat = $format;
}
}