When you place a named block, it loses its name tag, making it impossible to detect if it was ever named. What you can do, however, is set a custom data value:
/setblock ~ ~ ~ diamond_block 1
Then, replace detect ~ ~-1 ~ diamond_block 0
with diamond_block 1
. You can use values 1 through 15, but values above 15 are not supported.
Note: In some versions of the game (and possibly the latest updates), blocks with custom data may have a missing texture, and the custom data may not be saved properly. You'll have to look into this yourself as I can't test it at the moment.
Use a daylight sensor. By using redstone to check the output of the lamp, you can trigger an output line each dawn and evening. Use a T-flip-flop to reduce those 2 pulses to one long pulse every dawn. Connect that to a command block which summons an item into a hopper which points into a chest.
When the player presses the button, another hopper will take the items out of the chest. Run a comparator out of that hopper into a redstone clock. Set up the clock correctly so each item that passes through the hopper will turn the clock on and off once. Connect the clock to a commend block, set up to give whatever item to the player, or to summon it on the ground, or whatever other action.
The result: The number of dawns that have passed since the button was last pressed will be counted. When the button is pressed, the command block will run once for each dawn that passed. The recording of how many dawns have passed will be set to 0, ready for the next button press.
I saw in a comment that you had trouble with people griefing the daylight sensor. If that is a problem, just move the entire command block setup somewhere that no one can reach. For example, very high up, or a million blocks away. Even though there are no barrier blocks in 1.7, you can still use bedrock to stop players getting in. If they are able to reach the daylight sensor still, then add a command block which executes every tick and places a daylight sensor if there isn't one already there. The result: The daylight sensor cannot be permanently broken and no other parts can be reached.
EDIT: The command to place a new daylight sensor only if it has been removed should be:
setblock x y z minecraft:daylight_sensor 0 replace minecraft:air
Of course, replace x y z
with the correct coordinates of where the daylight sensor should go. Also, that command will need to be executed every tick. If you need instructions, read this article http://minecraft.gamepedia.com/Clock_circuit and scroll to the section "Setblock clock". Good luck!
Best Answer
That's not possible right now (1.9.4).
What you can do, is give the player a tag: (Put this command block behind the button)
Then (in repeating command block) put the command you want to execute:
Append your commands into Chain-command-blocks. Append a Chain-Command-block put this command:
To reset the machine.
The setup:
Hope it helped (: