Use -o option.
Write the resource use statistics to FILE instead of to the standard error stream. By default, this overwrites the file, destroying the file's previous contents. This option is useful for collecting information on interactive programs and programs that produce output on the standard error stream.
Code:
time -o output.txt myprog
cat output.txt
To append output use -a option
Code:
time -a output.txt myprog
cat output.txt