How does my iPhone know what time it is without service?

So I'm in another country with my iPhone 5 which isn't getting service at all from any tower but the clock on my phone is showing the correct local time. How is this possible without any signal?

It uses GPS to correct the time. GPS doesn't use cellular or internet connection at all.

Its using a time server which is accessed via Wi-Fi, not phone signal.

I'm using Nokia so doesn't know more about I phone but 1 thing is sure that your phone is using GPS service in that country.
For the signals Check the Telecommunication protocols in that country.