Reputation: 95
I am aware of the datetime library. However, on top of knowing the date and time of the world, I also need to know the date and time of the local server my application will be running on. The reason for this is because my local server is not connected to the internet so it may have a different date and time and I want to be able to detect it if that's the case. Any help would be appreciated.
Upvotes: 3
Views: 6856
Reputation: 745
There is also the time
module which has a localtime
method. However this just reformats time
.
import time
localTime = time.localtime()
print (localTime)
Upvotes: 1
Reputation: 13090
With the datetime
package, as you refer to, you can get the current local time e.g. by
import datetime
now = datetime.datetime.now()
print(now)
This is the local time on the machine. Python does not reach out to the world over the internet to ask what time it is.
Upvotes: 6