While not as neat or compact as your previous solution this allows you to easily change the start and end years as desired and a bit easier to understand. To keep it simple I don't mess with leap year.
Code:
#!/bin/bash
convertsecs() {
((h=${1}/3600))
((m=(${1}%3600)/60))
((s=${1}%60))
printf "%02d%02d.%02d" $h $m $s
}
start=2012
end=2016
num=$(shuf -i $start-$end -n 1)
day=$(shuf -i 0-364 -n 1)
tdate=$(date -d "$day days $num-01-01" +"%Y%m%d")
time=$(convertsecs $(shuf -i 0-86399 -n 1) )
echo $tdate$time
version 2 just calculates a random year/day and converts it to seconds instead of needing an additional function.
Code:
#!/bin/bash
start=2012
end=2016
interv=$((end-start))
sstart=$(date -d "$start-01-01" +%s)
num=$(shuf -i 0-$interv -n 1)
day=$(shuf -i 1-365 -n 1)
time=$(shuf -i 0-86399 -n 1)
yrs=$(( (num*365+day)*86400))
end=$((sstart+yrs+time))
tdate=$(date -d @$end +%C%y%m%d%H%M.%S)
echo $tdate