Unmanned aerial vehicles (UAVs) are increasingly becoming an integral part in many civilian and military applications. One of the main requirements for the UAV in such applications is the ability of the UAV to determine its location in an autonomous and real time manner. While many applications rely on the GPS system for this purpose, existing GPS based localization methods face many challenges and do not provide a highly reliable and accurate 3D positioning solution. The objective of this paper is to provide an accurate and real-time solution for the 3D localization of UAVs in an outdoor environment using existing 5G networks, independent of the GPS. We formulate the UAV localization as an optimization problem in which the drone uses the RSSI measurements of the surrounding 5G base stations, without having to actually interact with these base stations, to determine its location. We solve the formulated localization problem using a proper optimization technique to determine the optimal bound of the solution. Then, we propose a deep supervised learning approach to provide a localization solution with comparable accuracy for practical real-time dynamic applications.