I would like to convert the git date into the format of Ymd. Here's my attempt:
$>>git log -1 --format="%cd" | xargs date Y%m%d
But this returns this error:
date: extra operand ‘Thu’
Try 'date --help' for more information.
Any ideas how to convert git date like this:
Thu Sep 19 17:03:12 2013 +0100
To something like this:
20130919
Thanks.
It'd be easier if you make git emit the UNIX timestamp. Say:
git log -1 --format="%at" | xargs -I{} date -d @{} +%Y%m%d
From the documentation:
%at: author date, UNIX timestamp
Instead of using %cd, use %ct which would get the timestamp:
git log -1 --format="%ct" | xargs -i -- date -d '@{}' '+%Y%m%d'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With