Unix timestamp to datetime string












1















Given a unix timestamp as an input, give a datetime string, in a format like so: "YYMMDD.HHmm"



Rules




  • The input is a number (integer) of a millisecond-precise unix epoch (milliseconds since 1970 January 1st 00:00:00.000).

  • The values must be padded with zeroes if they are 1 character instead of 2. (e.g.: for "DD", "1" is not acceptable, but "01" is.)

  • The output must be a single string. No arrays.

  • Leap second handling doesn't matter.

  • Shortest wins.


Good luck!



Example



Input: 1547233866744
Output: 190111.1911









share|improve this question









New contributor




skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Welcome to PPCG! Nice challenge, but there are a few clarifications to be made. To make the challenge self-contained, you should probably explain what the Unix epoch is. Additionally, what should be done with leap seconds? What should be done with the Year 2038 problem?

    – AdmBorkBork
    1 hour ago











  • @AdmBorkBork Edited the post to explain what the Unix epoch is. Leap second implementation doesn't matter, since the output string is not second-precise. The Year 2038 problem doesn't currently matter since it could be a limitation of the running device or the chosen programming language.

    – skiilaa
    1 hour ago


















1















Given a unix timestamp as an input, give a datetime string, in a format like so: "YYMMDD.HHmm"



Rules




  • The input is a number (integer) of a millisecond-precise unix epoch (milliseconds since 1970 January 1st 00:00:00.000).

  • The values must be padded with zeroes if they are 1 character instead of 2. (e.g.: for "DD", "1" is not acceptable, but "01" is.)

  • The output must be a single string. No arrays.

  • Leap second handling doesn't matter.

  • Shortest wins.


Good luck!



Example



Input: 1547233866744
Output: 190111.1911









share|improve this question









New contributor




skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Welcome to PPCG! Nice challenge, but there are a few clarifications to be made. To make the challenge self-contained, you should probably explain what the Unix epoch is. Additionally, what should be done with leap seconds? What should be done with the Year 2038 problem?

    – AdmBorkBork
    1 hour ago











  • @AdmBorkBork Edited the post to explain what the Unix epoch is. Leap second implementation doesn't matter, since the output string is not second-precise. The Year 2038 problem doesn't currently matter since it could be a limitation of the running device or the chosen programming language.

    – skiilaa
    1 hour ago
















1












1








1








Given a unix timestamp as an input, give a datetime string, in a format like so: "YYMMDD.HHmm"



Rules




  • The input is a number (integer) of a millisecond-precise unix epoch (milliseconds since 1970 January 1st 00:00:00.000).

  • The values must be padded with zeroes if they are 1 character instead of 2. (e.g.: for "DD", "1" is not acceptable, but "01" is.)

  • The output must be a single string. No arrays.

  • Leap second handling doesn't matter.

  • Shortest wins.


Good luck!



Example



Input: 1547233866744
Output: 190111.1911









share|improve this question









New contributor




skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












Given a unix timestamp as an input, give a datetime string, in a format like so: "YYMMDD.HHmm"



Rules




  • The input is a number (integer) of a millisecond-precise unix epoch (milliseconds since 1970 January 1st 00:00:00.000).

  • The values must be padded with zeroes if they are 1 character instead of 2. (e.g.: for "DD", "1" is not acceptable, but "01" is.)

  • The output must be a single string. No arrays.

  • Leap second handling doesn't matter.

  • Shortest wins.


Good luck!



Example



Input: 1547233866744
Output: 190111.1911






code-golf date






share|improve this question









New contributor




skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 1 hour ago







skiilaa













New contributor




skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 hours ago









skiilaaskiilaa

1165




1165




New contributor




skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1





    Welcome to PPCG! Nice challenge, but there are a few clarifications to be made. To make the challenge self-contained, you should probably explain what the Unix epoch is. Additionally, what should be done with leap seconds? What should be done with the Year 2038 problem?

    – AdmBorkBork
    1 hour ago











  • @AdmBorkBork Edited the post to explain what the Unix epoch is. Leap second implementation doesn't matter, since the output string is not second-precise. The Year 2038 problem doesn't currently matter since it could be a limitation of the running device or the chosen programming language.

    – skiilaa
    1 hour ago
















  • 1





    Welcome to PPCG! Nice challenge, but there are a few clarifications to be made. To make the challenge self-contained, you should probably explain what the Unix epoch is. Additionally, what should be done with leap seconds? What should be done with the Year 2038 problem?

    – AdmBorkBork
    1 hour ago











  • @AdmBorkBork Edited the post to explain what the Unix epoch is. Leap second implementation doesn't matter, since the output string is not second-precise. The Year 2038 problem doesn't currently matter since it could be a limitation of the running device or the chosen programming language.

    – skiilaa
    1 hour ago










1




1





Welcome to PPCG! Nice challenge, but there are a few clarifications to be made. To make the challenge self-contained, you should probably explain what the Unix epoch is. Additionally, what should be done with leap seconds? What should be done with the Year 2038 problem?

– AdmBorkBork
1 hour ago





Welcome to PPCG! Nice challenge, but there are a few clarifications to be made. To make the challenge self-contained, you should probably explain what the Unix epoch is. Additionally, what should be done with leap seconds? What should be done with the Year 2038 problem?

– AdmBorkBork
1 hour ago













@AdmBorkBork Edited the post to explain what the Unix epoch is. Leap second implementation doesn't matter, since the output string is not second-precise. The Year 2038 problem doesn't currently matter since it could be a limitation of the running device or the chosen programming language.

– skiilaa
1 hour ago







@AdmBorkBork Edited the post to explain what the Unix epoch is. Leap second implementation doesn't matter, since the output string is not second-precise. The Year 2038 problem doesn't currently matter since it could be a limitation of the running device or the chosen programming language.

– skiilaa
1 hour ago












7 Answers
7






active

oldest

votes


















2















Bash + coreutils, 29 bytes





date -d@${1::-3} +%y%m%d.%H%M


Try it online!






share|improve this answer































    2















    PHP, 40 32 bytes



    -8 bytes thanks to Luis felipe





    <?=date('ymd.hi',$argv[1]/1000);


    Try it online!



    Simple naive answer. PHP's date function takes a format string and an integer timestamp. Input from cli arguments, which is a string by default, then /1000 because date expects second-precise timestamps. This also coerces the string to a number.






    share|improve this answer


























    • Nice answer! It's a tad shorter if the language has date formatting, yes :)

      – skiilaa
      1 hour ago











    • 32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string

      – Luis felipe De jesus Munoz
      1 hour ago













    • ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P

      – Skidsdev
      1 hour ago



















    1














    Javascript ES6, 76 bytes



    (d,c=-1,h=x=>(new Date(d)).toJSON().substr(c+=3,2))=>h()+h()+h()+"."+h()+h()


    Try it online





    (d, // timestamp
    c=-1, // counter, starting from -1. 3 is added to it every time, but the first time-part is
    // character from 2, and it starts growing by 3 from there
    h=x=>(new Date(d)).toJSON().substr(c+=3,2) // this function creates a date object from the
    // timestamp, and turns it into JSON (same as
    // toISOString), and substrings it. It
    // increments the counter every time by three,
    // and it reads 2 characters after that.
    )=>h()+h()+h()+"."+h()+h() // It runs the h function three times first, which gets the
    // year, month, and day, then adds a dot, and gets the hours and
    // minutes.





    share|improve this answer








    New contributor




    skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.
















    • 2





      You may want to wait a day or so before answering your own questions next time.

      – fəˈnɛtɪk
      1 hour ago











    • 71 bytes

      – Luis felipe De jesus Munoz
      1 hour ago











    • Alternative 71 bytes

      – Shaggy
      1 hour ago



















    0















    PowerShell, 59 bytes





    "{0:yyMMdd.HHmm}"-f(Date 1/1/1970).AddSeconds("$args"/1000)


    Try it online!



    Gets the Date of 1/1/1970 (defaults to 00:00:00am), then Adds the appropriate number of Seconds. Passes that to the -format operator, which correctly formats the datetime.



    Probably culture-dependent. This works on TIO, which is en-us.






    share|improve this answer































      0














      jq, 33 characters



      (30 characters code + 3 characters command line option)



      ./1000|strftime("%y%m%d.%H%M")


      Sample run:



      bash-4.4$ jq -r './1000|strftime("%y%m%d.%H%M")' <<< 1547233866744
      190111.1911


      Try it online!






      share|improve this answer
























      • You don't need to count command-line flags anymore.

        – AdmBorkBork
        1 hour ago











      • Oops. Good to know. Thank you @AdmBorkBork.

        – manatwork
        58 mins ago



















      0














      GNU AWK, 34 characters



      $0=strftime("%y%m%d.%H%M",$0/1000)


      (strftime() is GNU extension, will not run in other AWK implementations.)



      Sampler run:



      bash-4.4$ awk '$0=strftime("%y%m%d.%H%M",$0/1000)' <<< 1547233866744
      190111.2111


      Try it online!






      share|improve this answer































        0















        Perl 6,  111  89 bytes





        {~DateTime.new($_/Ⅿ,:formatter{"{(.year%Ⅽ,.month,.day).fmt('%02d','')}.{(.hour,.minute).fmt('%02d','')}"})}


        Try it (111)



        {TR/-//}o{S/..//}o{.yyyy-mm-dd~'.'~(.hour,.minute).fmt('%02d','')}o{DateTime.new($_/Ⅿ)}


        Try it (89)






        share|improve this answer

























          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "200"
          };
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          skiilaa is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178662%2funix-timestamp-to-datetime-string%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          7 Answers
          7






          active

          oldest

          votes








          7 Answers
          7






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2















          Bash + coreutils, 29 bytes





          date -d@${1::-3} +%y%m%d.%H%M


          Try it online!






          share|improve this answer




























            2















            Bash + coreutils, 29 bytes





            date -d@${1::-3} +%y%m%d.%H%M


            Try it online!






            share|improve this answer


























              2












              2








              2








              Bash + coreutils, 29 bytes





              date -d@${1::-3} +%y%m%d.%H%M


              Try it online!






              share|improve this answer














              Bash + coreutils, 29 bytes





              date -d@${1::-3} +%y%m%d.%H%M


              Try it online!







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 1 hour ago









              NeilNeil

              79.6k744177




              79.6k744177























                  2















                  PHP, 40 32 bytes



                  -8 bytes thanks to Luis felipe





                  <?=date('ymd.hi',$argv[1]/1000);


                  Try it online!



                  Simple naive answer. PHP's date function takes a format string and an integer timestamp. Input from cli arguments, which is a string by default, then /1000 because date expects second-precise timestamps. This also coerces the string to a number.






                  share|improve this answer


























                  • Nice answer! It's a tad shorter if the language has date formatting, yes :)

                    – skiilaa
                    1 hour ago











                  • 32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string

                    – Luis felipe De jesus Munoz
                    1 hour ago













                  • ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P

                    – Skidsdev
                    1 hour ago
















                  2















                  PHP, 40 32 bytes



                  -8 bytes thanks to Luis felipe





                  <?=date('ymd.hi',$argv[1]/1000);


                  Try it online!



                  Simple naive answer. PHP's date function takes a format string and an integer timestamp. Input from cli arguments, which is a string by default, then /1000 because date expects second-precise timestamps. This also coerces the string to a number.






                  share|improve this answer


























                  • Nice answer! It's a tad shorter if the language has date formatting, yes :)

                    – skiilaa
                    1 hour ago











                  • 32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string

                    – Luis felipe De jesus Munoz
                    1 hour ago













                  • ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P

                    – Skidsdev
                    1 hour ago














                  2












                  2








                  2








                  PHP, 40 32 bytes



                  -8 bytes thanks to Luis felipe





                  <?=date('ymd.hi',$argv[1]/1000);


                  Try it online!



                  Simple naive answer. PHP's date function takes a format string and an integer timestamp. Input from cli arguments, which is a string by default, then /1000 because date expects second-precise timestamps. This also coerces the string to a number.






                  share|improve this answer
















                  PHP, 40 32 bytes



                  -8 bytes thanks to Luis felipe





                  <?=date('ymd.hi',$argv[1]/1000);


                  Try it online!



                  Simple naive answer. PHP's date function takes a format string and an integer timestamp. Input from cli arguments, which is a string by default, then /1000 because date expects second-precise timestamps. This also coerces the string to a number.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 1 hour ago

























                  answered 1 hour ago









                  SkidsdevSkidsdev

                  6,3562974




                  6,3562974













                  • Nice answer! It's a tad shorter if the language has date formatting, yes :)

                    – skiilaa
                    1 hour ago











                  • 32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string

                    – Luis felipe De jesus Munoz
                    1 hour ago













                  • ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P

                    – Skidsdev
                    1 hour ago



















                  • Nice answer! It's a tad shorter if the language has date formatting, yes :)

                    – skiilaa
                    1 hour ago











                  • 32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string

                    – Luis felipe De jesus Munoz
                    1 hour ago













                  • ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P

                    – Skidsdev
                    1 hour ago

















                  Nice answer! It's a tad shorter if the language has date formatting, yes :)

                  – skiilaa
                  1 hour ago





                  Nice answer! It's a tad shorter if the language has date formatting, yes :)

                  – skiilaa
                  1 hour ago













                  32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string

                  – Luis felipe De jesus Munoz
                  1 hour ago







                  32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string

                  – Luis felipe De jesus Munoz
                  1 hour ago















                  ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P

                  – Skidsdev
                  1 hour ago





                  ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P

                  – Skidsdev
                  1 hour ago











                  1














                  Javascript ES6, 76 bytes



                  (d,c=-1,h=x=>(new Date(d)).toJSON().substr(c+=3,2))=>h()+h()+h()+"."+h()+h()


                  Try it online





                  (d, // timestamp
                  c=-1, // counter, starting from -1. 3 is added to it every time, but the first time-part is
                  // character from 2, and it starts growing by 3 from there
                  h=x=>(new Date(d)).toJSON().substr(c+=3,2) // this function creates a date object from the
                  // timestamp, and turns it into JSON (same as
                  // toISOString), and substrings it. It
                  // increments the counter every time by three,
                  // and it reads 2 characters after that.
                  )=>h()+h()+h()+"."+h()+h() // It runs the h function three times first, which gets the
                  // year, month, and day, then adds a dot, and gets the hours and
                  // minutes.





                  share|improve this answer








                  New contributor




                  skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.
















                  • 2





                    You may want to wait a day or so before answering your own questions next time.

                    – fəˈnɛtɪk
                    1 hour ago











                  • 71 bytes

                    – Luis felipe De jesus Munoz
                    1 hour ago











                  • Alternative 71 bytes

                    – Shaggy
                    1 hour ago
















                  1














                  Javascript ES6, 76 bytes



                  (d,c=-1,h=x=>(new Date(d)).toJSON().substr(c+=3,2))=>h()+h()+h()+"."+h()+h()


                  Try it online





                  (d, // timestamp
                  c=-1, // counter, starting from -1. 3 is added to it every time, but the first time-part is
                  // character from 2, and it starts growing by 3 from there
                  h=x=>(new Date(d)).toJSON().substr(c+=3,2) // this function creates a date object from the
                  // timestamp, and turns it into JSON (same as
                  // toISOString), and substrings it. It
                  // increments the counter every time by three,
                  // and it reads 2 characters after that.
                  )=>h()+h()+h()+"."+h()+h() // It runs the h function three times first, which gets the
                  // year, month, and day, then adds a dot, and gets the hours and
                  // minutes.





                  share|improve this answer








                  New contributor




                  skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.
















                  • 2





                    You may want to wait a day or so before answering your own questions next time.

                    – fəˈnɛtɪk
                    1 hour ago











                  • 71 bytes

                    – Luis felipe De jesus Munoz
                    1 hour ago











                  • Alternative 71 bytes

                    – Shaggy
                    1 hour ago














                  1












                  1








                  1







                  Javascript ES6, 76 bytes



                  (d,c=-1,h=x=>(new Date(d)).toJSON().substr(c+=3,2))=>h()+h()+h()+"."+h()+h()


                  Try it online





                  (d, // timestamp
                  c=-1, // counter, starting from -1. 3 is added to it every time, but the first time-part is
                  // character from 2, and it starts growing by 3 from there
                  h=x=>(new Date(d)).toJSON().substr(c+=3,2) // this function creates a date object from the
                  // timestamp, and turns it into JSON (same as
                  // toISOString), and substrings it. It
                  // increments the counter every time by three,
                  // and it reads 2 characters after that.
                  )=>h()+h()+h()+"."+h()+h() // It runs the h function three times first, which gets the
                  // year, month, and day, then adds a dot, and gets the hours and
                  // minutes.





                  share|improve this answer








                  New contributor




                  skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  Javascript ES6, 76 bytes



                  (d,c=-1,h=x=>(new Date(d)).toJSON().substr(c+=3,2))=>h()+h()+h()+"."+h()+h()


                  Try it online





                  (d, // timestamp
                  c=-1, // counter, starting from -1. 3 is added to it every time, but the first time-part is
                  // character from 2, and it starts growing by 3 from there
                  h=x=>(new Date(d)).toJSON().substr(c+=3,2) // this function creates a date object from the
                  // timestamp, and turns it into JSON (same as
                  // toISOString), and substrings it. It
                  // increments the counter every time by three,
                  // and it reads 2 characters after that.
                  )=>h()+h()+h()+"."+h()+h() // It runs the h function three times first, which gets the
                  // year, month, and day, then adds a dot, and gets the hours and
                  // minutes.






                  share|improve this answer








                  New contributor




                  skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 2 hours ago









                  skiilaaskiilaa

                  1165




                  1165




                  New contributor




                  skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  skiilaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.








                  • 2





                    You may want to wait a day or so before answering your own questions next time.

                    – fəˈnɛtɪk
                    1 hour ago











                  • 71 bytes

                    – Luis felipe De jesus Munoz
                    1 hour ago











                  • Alternative 71 bytes

                    – Shaggy
                    1 hour ago














                  • 2





                    You may want to wait a day or so before answering your own questions next time.

                    – fəˈnɛtɪk
                    1 hour ago











                  • 71 bytes

                    – Luis felipe De jesus Munoz
                    1 hour ago











                  • Alternative 71 bytes

                    – Shaggy
                    1 hour ago








                  2




                  2





                  You may want to wait a day or so before answering your own questions next time.

                  – fəˈnɛtɪk
                  1 hour ago





                  You may want to wait a day or so before answering your own questions next time.

                  – fəˈnɛtɪk
                  1 hour ago













                  71 bytes

                  – Luis felipe De jesus Munoz
                  1 hour ago





                  71 bytes

                  – Luis felipe De jesus Munoz
                  1 hour ago













                  Alternative 71 bytes

                  – Shaggy
                  1 hour ago





                  Alternative 71 bytes

                  – Shaggy
                  1 hour ago











                  0















                  PowerShell, 59 bytes





                  "{0:yyMMdd.HHmm}"-f(Date 1/1/1970).AddSeconds("$args"/1000)


                  Try it online!



                  Gets the Date of 1/1/1970 (defaults to 00:00:00am), then Adds the appropriate number of Seconds. Passes that to the -format operator, which correctly formats the datetime.



                  Probably culture-dependent. This works on TIO, which is en-us.






                  share|improve this answer




























                    0















                    PowerShell, 59 bytes





                    "{0:yyMMdd.HHmm}"-f(Date 1/1/1970).AddSeconds("$args"/1000)


                    Try it online!



                    Gets the Date of 1/1/1970 (defaults to 00:00:00am), then Adds the appropriate number of Seconds. Passes that to the -format operator, which correctly formats the datetime.



                    Probably culture-dependent. This works on TIO, which is en-us.






                    share|improve this answer


























                      0












                      0








                      0








                      PowerShell, 59 bytes





                      "{0:yyMMdd.HHmm}"-f(Date 1/1/1970).AddSeconds("$args"/1000)


                      Try it online!



                      Gets the Date of 1/1/1970 (defaults to 00:00:00am), then Adds the appropriate number of Seconds. Passes that to the -format operator, which correctly formats the datetime.



                      Probably culture-dependent. This works on TIO, which is en-us.






                      share|improve this answer














                      PowerShell, 59 bytes





                      "{0:yyMMdd.HHmm}"-f(Date 1/1/1970).AddSeconds("$args"/1000)


                      Try it online!



                      Gets the Date of 1/1/1970 (defaults to 00:00:00am), then Adds the appropriate number of Seconds. Passes that to the -format operator, which correctly formats the datetime.



                      Probably culture-dependent. This works on TIO, which is en-us.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 1 hour ago









                      AdmBorkBorkAdmBorkBork

                      26.4k364229




                      26.4k364229























                          0














                          jq, 33 characters



                          (30 characters code + 3 characters command line option)



                          ./1000|strftime("%y%m%d.%H%M")


                          Sample run:



                          bash-4.4$ jq -r './1000|strftime("%y%m%d.%H%M")' <<< 1547233866744
                          190111.1911


                          Try it online!






                          share|improve this answer
























                          • You don't need to count command-line flags anymore.

                            – AdmBorkBork
                            1 hour ago











                          • Oops. Good to know. Thank you @AdmBorkBork.

                            – manatwork
                            58 mins ago
















                          0














                          jq, 33 characters



                          (30 characters code + 3 characters command line option)



                          ./1000|strftime("%y%m%d.%H%M")


                          Sample run:



                          bash-4.4$ jq -r './1000|strftime("%y%m%d.%H%M")' <<< 1547233866744
                          190111.1911


                          Try it online!






                          share|improve this answer
























                          • You don't need to count command-line flags anymore.

                            – AdmBorkBork
                            1 hour ago











                          • Oops. Good to know. Thank you @AdmBorkBork.

                            – manatwork
                            58 mins ago














                          0












                          0








                          0







                          jq, 33 characters



                          (30 characters code + 3 characters command line option)



                          ./1000|strftime("%y%m%d.%H%M")


                          Sample run:



                          bash-4.4$ jq -r './1000|strftime("%y%m%d.%H%M")' <<< 1547233866744
                          190111.1911


                          Try it online!






                          share|improve this answer













                          jq, 33 characters



                          (30 characters code + 3 characters command line option)



                          ./1000|strftime("%y%m%d.%H%M")


                          Sample run:



                          bash-4.4$ jq -r './1000|strftime("%y%m%d.%H%M")' <<< 1547233866744
                          190111.1911


                          Try it online!







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 1 hour ago









                          manatworkmanatwork

                          16.2k43572




                          16.2k43572













                          • You don't need to count command-line flags anymore.

                            – AdmBorkBork
                            1 hour ago











                          • Oops. Good to know. Thank you @AdmBorkBork.

                            – manatwork
                            58 mins ago



















                          • You don't need to count command-line flags anymore.

                            – AdmBorkBork
                            1 hour ago











                          • Oops. Good to know. Thank you @AdmBorkBork.

                            – manatwork
                            58 mins ago

















                          You don't need to count command-line flags anymore.

                          – AdmBorkBork
                          1 hour ago





                          You don't need to count command-line flags anymore.

                          – AdmBorkBork
                          1 hour ago













                          Oops. Good to know. Thank you @AdmBorkBork.

                          – manatwork
                          58 mins ago





                          Oops. Good to know. Thank you @AdmBorkBork.

                          – manatwork
                          58 mins ago











                          0














                          GNU AWK, 34 characters



                          $0=strftime("%y%m%d.%H%M",$0/1000)


                          (strftime() is GNU extension, will not run in other AWK implementations.)



                          Sampler run:



                          bash-4.4$ awk '$0=strftime("%y%m%d.%H%M",$0/1000)' <<< 1547233866744
                          190111.2111


                          Try it online!






                          share|improve this answer




























                            0














                            GNU AWK, 34 characters



                            $0=strftime("%y%m%d.%H%M",$0/1000)


                            (strftime() is GNU extension, will not run in other AWK implementations.)



                            Sampler run:



                            bash-4.4$ awk '$0=strftime("%y%m%d.%H%M",$0/1000)' <<< 1547233866744
                            190111.2111


                            Try it online!






                            share|improve this answer


























                              0












                              0








                              0







                              GNU AWK, 34 characters



                              $0=strftime("%y%m%d.%H%M",$0/1000)


                              (strftime() is GNU extension, will not run in other AWK implementations.)



                              Sampler run:



                              bash-4.4$ awk '$0=strftime("%y%m%d.%H%M",$0/1000)' <<< 1547233866744
                              190111.2111


                              Try it online!






                              share|improve this answer













                              GNU AWK, 34 characters



                              $0=strftime("%y%m%d.%H%M",$0/1000)


                              (strftime() is GNU extension, will not run in other AWK implementations.)



                              Sampler run:



                              bash-4.4$ awk '$0=strftime("%y%m%d.%H%M",$0/1000)' <<< 1547233866744
                              190111.2111


                              Try it online!







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered 1 hour ago









                              manatworkmanatwork

                              16.2k43572




                              16.2k43572























                                  0















                                  Perl 6,  111  89 bytes





                                  {~DateTime.new($_/Ⅿ,:formatter{"{(.year%Ⅽ,.month,.day).fmt('%02d','')}.{(.hour,.minute).fmt('%02d','')}"})}


                                  Try it (111)



                                  {TR/-//}o{S/..//}o{.yyyy-mm-dd~'.'~(.hour,.minute).fmt('%02d','')}o{DateTime.new($_/Ⅿ)}


                                  Try it (89)






                                  share|improve this answer






























                                    0















                                    Perl 6,  111  89 bytes





                                    {~DateTime.new($_/Ⅿ,:formatter{"{(.year%Ⅽ,.month,.day).fmt('%02d','')}.{(.hour,.minute).fmt('%02d','')}"})}


                                    Try it (111)



                                    {TR/-//}o{S/..//}o{.yyyy-mm-dd~'.'~(.hour,.minute).fmt('%02d','')}o{DateTime.new($_/Ⅿ)}


                                    Try it (89)






                                    share|improve this answer




























                                      0












                                      0








                                      0








                                      Perl 6,  111  89 bytes





                                      {~DateTime.new($_/Ⅿ,:formatter{"{(.year%Ⅽ,.month,.day).fmt('%02d','')}.{(.hour,.minute).fmt('%02d','')}"})}


                                      Try it (111)



                                      {TR/-//}o{S/..//}o{.yyyy-mm-dd~'.'~(.hour,.minute).fmt('%02d','')}o{DateTime.new($_/Ⅿ)}


                                      Try it (89)






                                      share|improve this answer
















                                      Perl 6,  111  89 bytes





                                      {~DateTime.new($_/Ⅿ,:formatter{"{(.year%Ⅽ,.month,.day).fmt('%02d','')}.{(.hour,.minute).fmt('%02d','')}"})}


                                      Try it (111)



                                      {TR/-//}o{S/..//}o{.yyyy-mm-dd~'.'~(.hour,.minute).fmt('%02d','')}o{DateTime.new($_/Ⅿ)}


                                      Try it (89)







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 37 mins ago

























                                      answered 49 mins ago









                                      Brad Gilbert b2gillsBrad Gilbert b2gills

                                      12.1k11232




                                      12.1k11232






















                                          skiilaa is a new contributor. Be nice, and check out our Code of Conduct.










                                          draft saved

                                          draft discarded


















                                          skiilaa is a new contributor. Be nice, and check out our Code of Conduct.













                                          skiilaa is a new contributor. Be nice, and check out our Code of Conduct.












                                          skiilaa is a new contributor. Be nice, and check out our Code of Conduct.
















                                          If this is an answer to a challenge…




                                          • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                          • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                            Explanations of your answer make it more interesting to read and are very much encouraged.


                                          • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                          More generally…




                                          • …Please make sure to answer the question and provide sufficient detail.


                                          • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178662%2funix-timestamp-to-datetime-string%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Liste der Baudenkmale in Friedland (Mecklenburg)

                                          Single-Malt-Whisky

                                          Czorneboh