You can do this easily with zsh’s standard features. I love having years of my command history! It's all combined across sessions and instantly searchable with the standard ^R.
These are most of the settings in ZSH I use to enable all that.
HISTSIZE=10000000
SAVEHIST=10000000
setopt EXTENDED_HISTORY # logs the start and elapsed time
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
Thank you, this was so timely. My zsh terminals have been saving my command history but, for reasons I didn't know, were not displaying them. I'm much pleased to have that sorted out.
Xonsh lets you log history to a sqlite database. It’s a nifty feature for analysing what you’re doing in your shell and AFAIK it keeps the start/stop/elapsed time too.
https://spin.atomicobject.com/2016/05/28/log-bash-history/