How can I get the last 2 digits of:
200912
to my object:
$year = $flightDates-&
You can just address it as string, the function substr will convert it automatically:
departureDate->year;
echo substr( $year, -2 );
?>
Take a closer look at substr function. If you want the result to be a strict integer, then just add (int) in front of the return.
But, as Jan. said, you should better work with it as a date:
departureDate->year;
$date = DateTime::createFromFormat( 'dmy', $year );
echo date( "y", $date->getTimestamp() );
?>