Minecraft – How to set Command Block(s) to test for a particular time and output a message

minecraft-commandsminecraft-java-edition

I simply want one command block to test for the time of day or night (e.g. time = 18000) and output a message in the chat to everyone if that time returns true.

I was trying a simple set-up with two command blocks and a comparator in the middle, but I'm a beginner and am obviously missing the correct syntax (especially to test for a particular time of day, and if true, then trigger the say "message" block).

ETA: Kudos to @Ben for the Daylight Sensor/Redstone idea, but I'd really prefer a Command Block solution for the above, since my plan is to output several messages during the day and night cycle at very specific times in the world. Thanks.

Best Answer

An easier option might be to use a daylight sensor. Set it up with a string of Redstone and see how far the signal is when you set the time (/time set 18000).

Then, you can do something tricky like this to invert the signal:

enter image description here

What this will do, is when the signal from the daylight sensor dies, the Redstone torch will be turned on, firing up the command block.

enter image description here