Format datetime as UTC with strftime (for use in git)
1
vote
1
answer
5045
views
I can format dates and time pretty flexibly with
strftime
, but from what I can see, this only will give times in my local timezone; I can add the timezone offset (e.g. '%Y %m %d-%H:%M:%S%z'
for a particular time yields 2022 02 14 16:21:35-0800
), but what I actually want is the datetime for UTC. (For that example, 2022 02 15 00:21:35
.) Is this possible with strftime
?
(Context: I'm fiddling with git log --date=format
trying to get a format which matches go.mod
fake versions. The --date=format:'%foo%bar'
option, for defining custom formats, delegates to system strftime
. I'm on Mac OSX Monterey and using bash. EDIT: Solution was somewhat more complex due to being used in git; changed the question description to reflect that.)
Asked by jkmartin
(113 rep)
Mar 3, 2022, 08:03 PM
Last activity: Mar 22, 2022, 08:37 PM
Last activity: Mar 22, 2022, 08:37 PM