How to find out the current Minecraft time in a command?

Hello!

I have a certain command and in this command I want to know the current Minecraft time, e. g. in ticks.

How can I get it?

I didn’t find anything remotely similar to time in the World class.

Thanks in advance

Dmitri

its a WorldProperties method
getWorldTime()
Gets the time of day, in ticks.

world.getProperties().getWorldTime()

1 Like

Many thanks, @TheBoomer!

Please note, that this isn’t just time, but the minecraft “date”.

Changing this value to 0 I believe will have effects of changing the “local time based difficulty” component of mob spawning, as well as changing the moon cycles.

If you are going to mess with minecraft time, try to only set it forwards, unless intentionally trying to lower the difficulty.

1 Like