// first two $year = substr($flightDates->departureDate->year,2); // last two $year = substr($flightDates->departureDate->year,-2);
但是考虑到你在这里解析一个日期,使用date函数会更加智慧.
体育strtotime()和date()或甚至:
<?PHP $someDate ='200912'; $dateObj = DateTime::createFromFormat('dmy',$someDate); echo $dateObj->format('Y'); // prints "2012" .. (see date formats)