How can I get the server time in Minecraft?

Solution 1:

Figured it out. The data is in the level.dat file. Assuming you're using Python, here's a code snippet that should get the current time (run "sudo pip install nbt" first):

import nbt
def get_time():
    n = nbt.NBTFile('%s/%s/level.dat' % (minecraft_dir, session_name))
    if n == None:
        return None
    else:
        return n[0]["Time"].value % 24000

For bonus points, you can change the modulo to a division sign and get how many days it has been since you started.