On OpenBSD 6.3 I can see:
foo# date
Sun Apr 1 17:00:45 CEST 2018
foo#
foo# date -d "Sun Apr 1 17:00:45 CEST 2018" +%s
1522594858
foo# date
Sun Apr 1 17:00:59 CEST 2018
foo#
that "date" doesn't supports the usual conversion.
The https://www.epochconverter.com/ says that the 1522594858 is:
Your time zone: Sunday, April 1, 2018 5:00:58 PM GMT+02:00 DST
So the date command I issued only returned the unix timestamp of the CURRENT time, not the time that I have given to convert: "Sun Apr 1 17:00:45 CEST 2018".
The Question: how to convert a given date to unix timestamp on OpenBSD? If not with the "date" command, what other shell tools could do it?
First I started to read: https://man.openbsd.org/date – but didn't find anything about converting to unix timestamp. Then I tried to google for many examples, but didn't helped.
Best Answer
The OpenBSD
date
utility is used to[[[[[[cc]yy]mm]dd]HH]MM[.SS]]
without setting the system's time, using the-j
option.It is not date conversion tool that is as flexible as GNU
date
in its parsing capabilities. If you want GNUdate
time/date parsing capabilities, install thecoreutils
port/package and usegdate
instead.Also note that the
-d
option for OpenBSD'sdate
is used to set the system's value for daylight saving.