git: timezone and timestamp format

后端 未结 8 690
遥遥无期
遥遥无期 2020-12-01 08:42

From git I can get the timestamp:

\"2011-10-04 12:58:36 -0600\"

but is there any way to show it as:

\"2011-10-04 06:58:36\"         


        
8条回答
  •  清歌不尽
    2020-12-01 09:21

    If you want to display the git date in YYYY-MM-DD HH:MM:SS format:

    DATE=$(git log -n 1 --pretty=format:"%ad" --date=iso)
    echo "Date: ${DATE::20}"

提交回复
热议问题