Loris Brljafa, 21, pleaded guilty as he was arraigned at the Koper District Court on Tuesday, almost six months after he was arrested at the Dragonja border crossing.
The border checkpoint was closed for several hours on 25 January when police discovered what looked like an explosives belt under the seat of a bus.
Brljafa had not resisted arrest and has cooperated with investigators since. He told investigators he had planned to go to the capital Ljubljana to cause a scare.
Prosecutor Jože Levašič said Brljafa was a troubled loner and had become radicalized with online videos. He considered himself a supporter of Islamic State.
According to the prosecutor, this was the case of charges being brought in Slovenia for travelling for the purposes of terrorism.
The defence counsel, Nikica Kljajić, said the sentence was fair.
The charge carries a prison sentence of between one and eight years in Slovenia.
Brljafa regretted his act as "great stupidity". The judge, Julijan Glavina, urged the defendant to undergo psychiatric treatment while in prison because he has serious psychological problems.