如何获取以下的最后2位数字:200912我的对象:$year=$flightDates->departureDate->year; 最佳答案 //firsttwo$year=substr($flightDates->departureDate->year,0,2);//lasttwo$year=substr($flightDates->departureDate->year,-2);但考虑到您要在此处解析日期,使用日期函数会更明智。体育strtotime()和date()甚至:format('Y');//prints"2012"..