Output of a shell command can be written to a file by using > but if you don’t want to overwrite the contents of the file then you can use >> to write to the end of the file.
The below will write the date to a file in /var/log:
date > /var/log/currenttime
The below will write the date to a file in /var/log without overwriting anything already in the file:
date >> /var/log/currenttime