Metropolitan Magistrate Nurunnahar Yesmin passed the order on Thursday afternoon.
Earlier in the day, police produced them before the court with a 10-day remand plea.
The plea stated that Hasnat downloaded an app – Wickr – 10 minutes after the militants took 22 people hostage at Holey Artisan Bakery on July 1.
They were arrested under Section 54 on Wednesday night for their alleged involvement in the attack.
Police’s Detective Branch said they arrested Tahmid from his house at Baridhara around 8:45pm while Hasnat was picked up from in front of Aarong in Gulshan around 8:30pm.
Armed terrorists barged into an upmarket restaurant, popular with foreigners, at the heart of Dhaka’s diplomatic zone and killed 22 people, including 17 foreigners.
The whereabouts of Hasnat, a former private university teacher, and Tahmid, a student of University of Toronto, remained a mystery although police claimed the duo had been released after debriefing.
Both their families had told the Dhaka Tribune that none of them had returned home.
At a media conference on Tuesday, police chief Shahidul Hoque said former NSU teacher Hasnat was still a person of interest in the case.