root@monitor:/home/andrian # date +%s -d "Wed Apr 22 17:19:39 EEST 2021"
date: illegal time format
usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]]
[-I[date | hours | minutes | seconds]]
[-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]
No!Is that what you're after?Code:$ echo "Wed Apr 22 16:15:27 EEST 2021" |awk -F: '{print substr($3,1,2)}' 27
root@monitor:/home/andrian # date +%s
1587566566
root@monitor:/home/andrian # date
Wed Apr 22 17:43:30 EEST 2020
# date +%s -j -d Wed Apr 22 17:19:39 EEST 2021
and get 1658756656
% date -j -f "%a %b %d %T %Y" "Wed Apr 22 17:43:30 2021" "+%s"
1619106210
% date -j -f "%a %b %d %T %Z %Y" "Wed Apr 22 17:43:30 EEST 2021" "+%s"
Failed conversion of ``Wed Apr 22 17:43:30 EEST 2021'' using format ``%a %b %d %T %Z %Y''
date: illegal time format
usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]]
[-I[date | hours | minutes | seconds]]
[-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]
So! Thank you! You super! What you need!Can't get it to work with the timezone for some reason:
Adding the timezone fails:Code:% date -j -f "%a %b %d %T %Y" "Wed Apr 22 17:43:30 2021" "+%s" 1619106210
Code:% date -j -f "%a %b %d %T %Z %Y" "Wed Apr 22 17:43:30 EEST 2021" "+%s" Failed conversion of ``Wed Apr 22 17:43:30 EEST 2021'' using format ``%a %b %d %T %Z %Y'' date: illegal time format usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]] [-I[date | hours | minutes | seconds]] [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]
%Z is replaced by the time zone name.
%z is replaced by the time zone offset from UTC; a leading plus sign
stands for east of UTC, a minus sign for west of UTC, hours and
minutes follow with two digits each and no delimiter between them
(common form for RFC 822 date headers).
dice@hosaka:~ % date -j -f "%a %b %d %T %Z %Y" "Wed Apr 22 17:43:30 CEST 2021" "+%s"
1619106210
dice@hosaka:~ % date -j -f "%a %b %d %T %Z %Y" "Wed Apr 22 17:43:30 CET 2021" "+%s"
Failed conversion of ``Wed Apr 22 17:43:30 CET 2021'' using format ``%a %b %d %T %Z %Y''
date: illegal time format
usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]]
[-I[date | hours | minutes | seconds]]
[-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]