If you prefer to use the given command to obtain a daylight detector, here’s how you can use it in Minecraft Java Edition (PC/Mac):
Version 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, and 1.19.4:
/give @p daylight_detector 1
Version 1.8, 1.9, 1.10, 1.11, and 1.12:
/give @p daylight_detector 1 0