Convert a date to UNIX timestamp on OpenBSD

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite
1












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.







share|improve this question


















  • 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














up vote
1
down vote

favorite
1












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.







share|improve this question


















  • 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












up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





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.







share|improve this question














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.









share|improve this question













share|improve this question




share|improve this question








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 be YYmmddHHMMSS (unlike FreeBSD, there is no -f flag)
    – Mikel
    Apr 1 at 15:36












  • 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







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










2 Answers
2






active

oldest

votes

















up vote
2
down vote













The OpenBSD date utility is used to



  1. set the date and/or time on the system, or

  2. display the current date and/or time, or

  3. 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.






share|improve this answer






















  • Although that tool comes with its own problems. unix.stackexchange.com/a/422978/5132
    – JdeBP
    Apr 1 at 15:51

















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.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    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






























    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



    1. set the date and/or time on the system, or

    2. display the current date and/or time, or

    3. 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.






    share|improve this answer






















    • Although that tool comes with its own problems. unix.stackexchange.com/a/422978/5132
      – JdeBP
      Apr 1 at 15:51














    up vote
    2
    down vote













    The OpenBSD date utility is used to



    1. set the date and/or time on the system, or

    2. display the current date and/or time, or

    3. 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.






    share|improve this answer






















    • Although that tool comes with its own problems. unix.stackexchange.com/a/422978/5132
      – JdeBP
      Apr 1 at 15:51












    up vote
    2
    down vote










    up vote
    2
    down vote









    The OpenBSD date utility is used to



    1. set the date and/or time on the system, or

    2. display the current date and/or time, or

    3. 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.






    share|improve this answer














    The OpenBSD date utility is used to



    1. set the date and/or time on the system, or

    2. display the current date and/or time, or

    3. 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.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    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
















    • 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












    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.






    share|improve this answer
























      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.






      share|improve this answer






















        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 1 at 22:48









        Isaac

        6,5821734




        6,5821734






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            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













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?