Convert a date to UNIX timestamp on OpenBSD
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
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.
date openbsd
add a comment |Â
up vote
1
down vote
favorite
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.
date openbsd
1
The man page also mentions a-j
flag. That seems like it could be useful. But it seems like the input format must beYYmmddHHMMSS
(unlike FreeBSD, there is no-f
flag)
â Mikel
Apr 1 at 15:36
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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.
date openbsd
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.
date openbsd
edited Apr 1 at 15:22
Kusalananda
102k13201317
102k13201317
asked Apr 1 at 15:05
Hessnov
31314
31314
1
The man page also mentions a-j
flag. That seems like it could be useful. But it seems like the input format must beYYmmddHHMMSS
(unlike FreeBSD, there is no-f
flag)
â Mikel
Apr 1 at 15:36
add a comment |Â
1
The man page also mentions a-j
flag. That seems like it could be useful. But it seems like the input format must beYYmmddHHMMSS
(unlike FreeBSD, there is no-f
flag)
â Mikel
Apr 1 at 15:36
1
1
The man page also mentions a
-j
flag. That seems like it could be useful. But it seems like the input format must be YYmmddHHMMSS
(unlike FreeBSD, there is no -f
flag)â Mikel
Apr 1 at 15:36
The man page also mentions a
-j
flag. That seems like it could be useful. But it seems like the input format must be YYmmddHHMMSS
(unlike FreeBSD, there is no -f
flag)â Mikel
Apr 1 at 15:36
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
The OpenBSD date
utility is used to
- set the date and/or time on the system, or
- display the current date and/or time, or
- parse the time and date on the format
[[[[[[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 GNU date
time/date parsing capabilities, install the coreutils
port/package and use gdate
instead.
Also note that the -d
option for OpenBSD's date
is used to set the system's value for daylight saving.
Although that tool comes with its own problems. unix.stackexchange.com/a/422978/5132
â JdeBP
Apr 1 at 15:51
add a comment |Â
up vote
0
down vote
A smaller executable is busybox. It may do date:
$ busybox date -D '%a %b %-d %T %Z %Y' -d 'Sun Apr 1 17:00:45 CEST 2018' +%s
1522616445
The -D
describes the format used to parse the string in -d
.
Mind that it does not parse the CEST
value, it assumes TZ=UTC.
That is not a problem for a seconds timestamp as it is always at UTC+0.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
The OpenBSD date
utility is used to
- set the date and/or time on the system, or
- display the current date and/or time, or
- parse the time and date on the format
[[[[[[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 GNU date
time/date parsing capabilities, install the coreutils
port/package and use gdate
instead.
Also note that the -d
option for OpenBSD's date
is used to set the system's value for daylight saving.
Although that tool comes with its own problems. unix.stackexchange.com/a/422978/5132
â JdeBP
Apr 1 at 15:51
add a comment |Â
up vote
2
down vote
The OpenBSD date
utility is used to
- set the date and/or time on the system, or
- display the current date and/or time, or
- parse the time and date on the format
[[[[[[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 GNU date
time/date parsing capabilities, install the coreutils
port/package and use gdate
instead.
Also note that the -d
option for OpenBSD's date
is used to set the system's value for daylight saving.
Although that tool comes with its own problems. unix.stackexchange.com/a/422978/5132
â JdeBP
Apr 1 at 15:51
add a comment |Â
up vote
2
down vote
up vote
2
down vote
The OpenBSD date
utility is used to
- set the date and/or time on the system, or
- display the current date and/or time, or
- parse the time and date on the format
[[[[[[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 GNU date
time/date parsing capabilities, install the coreutils
port/package and use gdate
instead.
Also note that the -d
option for OpenBSD's date
is used to set the system's value for daylight saving.
The OpenBSD date
utility is used to
- set the date and/or time on the system, or
- display the current date and/or time, or
- parse the time and date on the format
[[[[[[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 GNU date
time/date parsing capabilities, install the coreutils
port/package and use gdate
instead.
Also note that the -d
option for OpenBSD's date
is used to set the system's value for daylight saving.
edited Apr 1 at 15:54
answered Apr 1 at 15:18
Kusalananda
102k13201317
102k13201317
Although that tool comes with its own problems. unix.stackexchange.com/a/422978/5132
â JdeBP
Apr 1 at 15:51
add a comment |Â
Although that tool comes with its own problems. unix.stackexchange.com/a/422978/5132
â JdeBP
Apr 1 at 15:51
Although that tool comes with its own problems. unix.stackexchange.com/a/422978/5132
â JdeBP
Apr 1 at 15:51
Although that tool comes with its own problems. unix.stackexchange.com/a/422978/5132
â JdeBP
Apr 1 at 15:51
add a comment |Â
up vote
0
down vote
A smaller executable is busybox. It may do date:
$ busybox date -D '%a %b %-d %T %Z %Y' -d 'Sun Apr 1 17:00:45 CEST 2018' +%s
1522616445
The -D
describes the format used to parse the string in -d
.
Mind that it does not parse the CEST
value, it assumes TZ=UTC.
That is not a problem for a seconds timestamp as it is always at UTC+0.
add a comment |Â
up vote
0
down vote
A smaller executable is busybox. It may do date:
$ busybox date -D '%a %b %-d %T %Z %Y' -d 'Sun Apr 1 17:00:45 CEST 2018' +%s
1522616445
The -D
describes the format used to parse the string in -d
.
Mind that it does not parse the CEST
value, it assumes TZ=UTC.
That is not a problem for a seconds timestamp as it is always at UTC+0.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
A smaller executable is busybox. It may do date:
$ busybox date -D '%a %b %-d %T %Z %Y' -d 'Sun Apr 1 17:00:45 CEST 2018' +%s
1522616445
The -D
describes the format used to parse the string in -d
.
Mind that it does not parse the CEST
value, it assumes TZ=UTC.
That is not a problem for a seconds timestamp as it is always at UTC+0.
A smaller executable is busybox. It may do date:
$ busybox date -D '%a %b %-d %T %Z %Y' -d 'Sun Apr 1 17:00:45 CEST 2018' +%s
1522616445
The -D
describes the format used to parse the string in -d
.
Mind that it does not parse the CEST
value, it assumes TZ=UTC.
That is not a problem for a seconds timestamp as it is always at UTC+0.
answered Apr 1 at 22:48
Isaac
6,5821734
6,5821734
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f434844%2fconvert-a-date-to-unix-timestamp-on-openbsd%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
The man page also mentions a
-j
flag. That seems like it could be useful. But it seems like the input format must beYYmmddHHMMSS
(unlike FreeBSD, there is no-f
flag)â Mikel
Apr 1 at 15:36