I've got an arbitrary time stamp 1427792481
I'm trying to implement +"%F"
so I just get 2015-03-31
How can I do this? My ideal goal would be to get 20150331
Asked
Active
Viewed 312 times
1

3kstc
- 4,706
3 Answers
2
You can try this:
date -d @1427792481 +"%F"
or for 20150331:
date -d @1427792481 +"%Y%m%d"

taliezin
- 9,275
2
A few options:
ksh93
or recentbash
, any system (shell builtin):printf "%(%Y%m%d)T\n" 1427792481
zsh
any system (builtin):zmodload zsh/datetime strftime %Y%m%d 1427792481
GNU
date
:date -d@1427792481 +%Y%m%d
GNU
awk
:awk 'BEGIN{print strftime("%Y%m%d", 1427792481)}'
perl
:perl -MPOSIX -le 'print strftime "%Y%m%d", localtime 1427792481'

Stéphane Chazelas
- 544,893