You can use getVersion() of YiiBase
getVersion()
Yii::getVersion();
In Linux, run ./yii in the base directory. In Windows, run yii.bat. You will get something like:
yii.bat
./yiiThis is Yii version 2.0.3.The following commands are available:[...]
grep -A 5 getVersion framework/YiiBase.php