unix set current time in file name

C++
echo "hello" > "$(date +"%Y_%m_%d_%I_%M_%p").txt"
Source

Also in C++: