Ubuntu – How to see time in ~/.bash_history file

bashbash-historygnome-terminalhistory

I added time to the ~/.bashrc file, so now it shows me time when I execute history command like this:

  376  04/10/19 20:39:52 sudo cat ~/.bash_history
  377  04/10/19 20:40:04 date
  378  07/10/19 10:13:29 echo 'HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
  379  07/10/19 10:13:38 source ~/.bashrc
  380  07/10/19 10:13:54 history
  381  07/10/19 10:20:08 sudo vim /home/subir/.bash_history 
  382  07/10/19 10:20:29 sudo nano /home/subir/.bash_history 
  383  07/10/19 11:34:20 cd ..
  384  07/10/19 11:34:34 find | grep .bash_history
  385  07/10/19 11:34:48 cat ./subir/.bash_history 
  386  07/10/19 11:37:32 history

But when this session's data gets appended to ~/.bash_history file then it shows something like this :

#1570201804
date
#1570423409
echo 'HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
#1570423418
source ~/.bashrc
#1570423434
history
#1570423808
sudo vim /home/subir/.bash_history 
#1570423829
sudo nano /home/subir/.bash_history 

What are the values after # ?. Can anyone help me deduce it's meaning or tell me a way to get timestamp in ~/.bash_history file.

Best Answer

That's Unix Timestamp / Epoch time - number of seconds passed from January 1st, 1970.

If you convert it to datetime, you will get:

$ date -d @1570201804
Fri Oct  4 18:10:04 EAT 2019

In UTC it is 10/04/2019 @ 3:10pm (UTC) but since I am in East Africa, we get +3 time difference coming to 10/04/2019 @ 6:10pm (UTC)

I guess your timezone is +5:30