Code:
ETIME=$(($DAY+$(date +_%H)*3600+$(date +%_M)*60+$(date +%_S)))
A little bug here. You have to invert the chars highlighted in red. Moreover note that the date format %_e is not needed, since %e is already padded with spaces (not an error, anyway).
An aside note: if I understand right, you want to check the execution time of your code. Why not simply compute the date in seconds since epoch (%s) before and after the block of code and check the difference? If you have simply to compute a difference you don't really need to set a reference time (midnight of the current day) and let date use its own reference (epoch). For example:
Code:
#!/bin/bash
BTIME=$(date -u +%s)
<code here>
ETIME=$(date -u +%s)
SECONDS=$((ETIME - BTIME))
echo $SECONDS
Note that -u for UTC time is needed to avoid confusion if you run the script during the passage from/to Daylight Saving Time.
Edit: I forgot to mention that SECONDS is not a good choice for a variable name, since $SECONDS is a bash built-in variable which returns the number of seconds since shell invocation (see man bash for details). This means that SECONDS is constantly updated and its value changes automatically during the execution of the script. Indeed, this could be the solution to your quest: just check the value of SECONDS after the block of code and the trick is done. I don't know about portability of this feature, anyway.
A last note: if you want to compute the execution time in hours, minutes and seconds, again you can let the date command do the job. For example:
Code:
date -ud @$SECONDS +"Execution time: %H:%M:%S"
Don't forget the -u option. Hope this helps!