Unix timestamp to datetime string












8












$begingroup$


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 time (milliseconds since 1970 January 1st 00:00:00.000 UTC).

  • 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











$endgroup$








  • 2




    $begingroup$
    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?
    $endgroup$
    – AdmBorkBork
    Jan 11 at 19:43






  • 1




    $begingroup$
    @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.
    $endgroup$
    – skiilaa
    Jan 11 at 19:50








  • 1




    $begingroup$
    Does the timezone matter?
    $endgroup$
    – Erik the Outgolfer
    Jan 11 at 21:52










  • $begingroup$
    I take it the year is represented by a two digit number?
    $endgroup$
    – Embodiment of Ignorance
    Jan 11 at 22:22






  • 1




    $begingroup$
    @FabianRöling timezones don't matter.
    $endgroup$
    – skiilaa
    Jan 12 at 18:04
















8












$begingroup$


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 time (milliseconds since 1970 January 1st 00:00:00.000 UTC).

  • 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











$endgroup$








  • 2




    $begingroup$
    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?
    $endgroup$
    – AdmBorkBork
    Jan 11 at 19:43






  • 1




    $begingroup$
    @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.
    $endgroup$
    – skiilaa
    Jan 11 at 19:50








  • 1




    $begingroup$
    Does the timezone matter?
    $endgroup$
    – Erik the Outgolfer
    Jan 11 at 21:52










  • $begingroup$
    I take it the year is represented by a two digit number?
    $endgroup$
    – Embodiment of Ignorance
    Jan 11 at 22:22






  • 1




    $begingroup$
    @FabianRöling timezones don't matter.
    $endgroup$
    – skiilaa
    Jan 12 at 18:04














8












8








8


1



$begingroup$


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 time (milliseconds since 1970 January 1st 00:00:00.000 UTC).

  • 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











$endgroup$




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 time (milliseconds since 1970 January 1st 00:00:00.000 UTC).

  • 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















share|improve this question













share|improve this question




share|improve this question








edited Jan 12 at 21:57









Community

1




1










asked Jan 11 at 19:27









skiilaaskiilaa

1638




1638








  • 2




    $begingroup$
    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?
    $endgroup$
    – AdmBorkBork
    Jan 11 at 19:43






  • 1




    $begingroup$
    @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.
    $endgroup$
    – skiilaa
    Jan 11 at 19:50








  • 1




    $begingroup$
    Does the timezone matter?
    $endgroup$
    – Erik the Outgolfer
    Jan 11 at 21:52










  • $begingroup$
    I take it the year is represented by a two digit number?
    $endgroup$
    – Embodiment of Ignorance
    Jan 11 at 22:22






  • 1




    $begingroup$
    @FabianRöling timezones don't matter.
    $endgroup$
    – skiilaa
    Jan 12 at 18:04














  • 2




    $begingroup$
    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?
    $endgroup$
    – AdmBorkBork
    Jan 11 at 19:43






  • 1




    $begingroup$
    @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.
    $endgroup$
    – skiilaa
    Jan 11 at 19:50








  • 1




    $begingroup$
    Does the timezone matter?
    $endgroup$
    – Erik the Outgolfer
    Jan 11 at 21:52










  • $begingroup$
    I take it the year is represented by a two digit number?
    $endgroup$
    – Embodiment of Ignorance
    Jan 11 at 22:22






  • 1




    $begingroup$
    @FabianRöling timezones don't matter.
    $endgroup$
    – skiilaa
    Jan 12 at 18:04








2




2




$begingroup$
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?
$endgroup$
– AdmBorkBork
Jan 11 at 19:43




$begingroup$
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?
$endgroup$
– AdmBorkBork
Jan 11 at 19:43




1




1




$begingroup$
@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.
$endgroup$
– skiilaa
Jan 11 at 19:50






$begingroup$
@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.
$endgroup$
– skiilaa
Jan 11 at 19:50






1




1




$begingroup$
Does the timezone matter?
$endgroup$
– Erik the Outgolfer
Jan 11 at 21:52




$begingroup$
Does the timezone matter?
$endgroup$
– Erik the Outgolfer
Jan 11 at 21:52












$begingroup$
I take it the year is represented by a two digit number?
$endgroup$
– Embodiment of Ignorance
Jan 11 at 22:22




$begingroup$
I take it the year is represented by a two digit number?
$endgroup$
– Embodiment of Ignorance
Jan 11 at 22:22




1




1




$begingroup$
@FabianRöling timezones don't matter.
$endgroup$
– skiilaa
Jan 12 at 18:04




$begingroup$
@FabianRöling timezones don't matter.
$endgroup$
– skiilaa
Jan 12 at 18:04










21 Answers
21






active

oldest

votes


















3












$begingroup$


Japt v1.4.5, 19 16 bytes



GîÐU s3)¤o>J i.G


1 byte saved thanks to Oliver, which led to another 2 bytes saved.



Try it





Explanation



GîÐU s3)¤o>J i.G
:Implicit input of integer U
G :16
î :Get the first 16 characters of the following string
ÐU : Convert U to a date object
s3 : Convert to ISO string
) :End get
¤ :Slice off the first 2 characters
o :Filter
>J : Greater than -1
i.G :Insert "." at 0-based index 16, with wrapping




Notes / Tips




  • Getting the first 16 characters of the ISO string and then slicing off the first two is a byte shorter than performing a single slice.


  • G is used to insert the . at the required index because using a literal 6 would cause it to be combined with the . and for that to be interpreted as a decimal that would be inserted at the start of the string. To get around that I'd need to add a ' before the . to force it to be interpreted as a string.

  • Japt v1.4.5 is used because Japt doesn't have a constant for 17 and from v1.4.6 on trying to insert something at the first index past the end of a string results in it being inserted at the end of the string (A is the Japt constant for 10) whereas prior to v1.4.6 it immediately wraps back to the beginning of the string.






share|improve this answer











$endgroup$





















    8












    $begingroup$

    JavaScript (ES6), 65 bytes



    n=>'101010.1010'.replace(i=/d/g,x=>new Date(n).toJSON()[i=x-~i])


    Try it online!



    How?



    We initialize the pointer $i$ to a non-numeric value (coerced to $0$) and then add alternately $2$ and $1$ to it to pick the relevant characters from the ISO-8601 conversion of the input timestamp.



    yyyy-mm-ddThh:mm:ss.sssZ
    ^^ ^^ ^^ ^^ ^^




    JavaScript (ES6), 66 bytes



    n=>'235689.BCEF'.replace(/w/g,x=>new Date(n).toJSON()[+`0x${x}`])


    Try it online!



    How?



    Once the input timestamp is converted in ISO-8601 format, all required characters can be accessed with a single hexadecimal digit.



    yyyy-mm-ddThh:mm:ss.sssZ
    ↓↓ ↓↓ ↓↓ ↓↓ ↓↓
    0123456789ABCDEF





    share|improve this answer











    $endgroup$













    • $begingroup$
      Wow. Just, wow.
      $endgroup$
      – skiilaa
      Jan 13 at 9:08






    • 1




      $begingroup$
      64 bytes: n=>'235689.11121415'.replace(/1?w/g,x=>new Date(n).toJSON()[x])
      $endgroup$
      – tsh
      Jan 14 at 7:02










    • $begingroup$
      @tsh Nice! I was not expecting the decimal format to be shorter. You may want to post this as a separate answer.
      $endgroup$
      – Arnauld
      Jan 14 at 15:45



















    7












    $begingroup$


    Bash + coreutils, 29 bytes





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


    Try it online!






    share|improve this answer









    $endgroup$





















      6












      $begingroup$


      PHP, 40 32 31 bytes



      -8 bytes thanks to Luis felipe
      -1 byte thanks to Jo King





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


      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 /1e3 because date expects second-precise timestamps. This also coerces the string to a number.






      share|improve this answer











      $endgroup$













      • $begingroup$
        Nice answer! It's a tad shorter if the language has date formatting, yes :)
        $endgroup$
        – skiilaa
        Jan 11 at 20:03










      • $begingroup$
        32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string
        $endgroup$
        – Luis felipe De jesus Munoz
        Jan 11 at 20:04












      • $begingroup$
        ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P
        $endgroup$
        – Skidsdev
        Jan 11 at 20:08










      • $begingroup$
        @JoKing ah nice one, thanks
        $endgroup$
        – Skidsdev
        Jan 14 at 14:03



















      5












      $begingroup$


      MATL, 28 bytes



      Thanks to @skiilaa for a correction in the output format.



      864e5/719529+'YYmmDD.HHMM'XO


      Try it online!



      Explanation



      MATL, like MATLAB, defines date/time numbers as the (possibly non-integer) number of days since time 00:00 of the reference "date" 0-Jan-0000.



      Thus we take the input, divide it by 86400000 (number of milliseconds in one day), add 719529 (number of days from MATL's reference to UNIX reference), and convert to the desired format 'YYmmDD.HHMM'.






      share|improve this answer











      $endgroup$





















        4












        $begingroup$

        GNU AWK, 34 33 characters



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


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



        Thanks to:





        • Jo King for suggesting E-notation (-1 character)


        Sampler run:



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


        Try it online!






        share|improve this answer











        $endgroup$













        • $begingroup$
          Thank you, @JoKing. Unfortunately E-notation is not really my friend so I always forget it.
          $endgroup$
          – manatwork
          Jan 13 at 16:02



















        4












        $begingroup$


        PowerShell, 59 58 bytes





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


        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.



        -1 byte thanks to shaggy.






        share|improve this answer











        $endgroup$





















          3












          $begingroup$


          Perl 6,  111 89  87 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)



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


          Try it (87)



          Explanation:



          The o infix operator takes two functions and creates a composite function. The rightmost one gets called first, and the one to the left gets called with its result.



          Basically we use 4 block lambdas to generate a single lambda.



          Which is not much different to how a WhateverCode lambda like * + * gets created.





          Divide by 1000 and use that to create a DateTime object.



          {DateTime.new($_/Ⅿ)} # Ⅿ is ROMAN NUMERAL ONE THOUSAND (3 bytes)


          The result gets used by:



          {
          .yyyy-mm-dd # 2019-01-11

          ~ '.' ~ # str concatenation with '.'

          ( .hour, .minute ).fmt('%02d') # add leading 0s (returns List)
          }


          That leaves us with a string like 2019-01-11.19 11



          We need to remove the first two digits



          {S/..//}


          We also need to remove - and



          {TR/- //}





          share|improve this answer











          $endgroup$





















            3












            $begingroup$


            Python 2, 64 bytes





            lambda s:strftime('%y%m%d.%H%M',gmtime(s/1e3))
            from time import*


            Try it online!



            The input is considered to be in UTC.






            share|improve this answer











            $endgroup$









            • 1




              $begingroup$
              Just as something I've been a bit confused on, is the only reason that the lambda comes before the import because it works better for TIO's header?
              $endgroup$
              – Neil A.
              Jan 11 at 22:43






            • 2




              $begingroup$
              @NeilA. Yes. The import can go either before or after, the contents of the lambda aren't checked for NameErrors before it's called.
              $endgroup$
              – Erik the Outgolfer
              Jan 11 at 22:45



















            3












            $begingroup$


            R, 58 56 bytes





            format(as.POSIXct(scan()/1e3,,'1970-1-1'),'%y%m%d.%H%M')


            Try it online!






            share|improve this answer











            $endgroup$





















              3












              $begingroup$


              C (gcc) (32-bit, little endian), 67 bytes





              f(t,s)long long t;{t/=1e3;strftime(s,12,"%y%m%d.%H%M",gmtime(&t));}


              Try it online!



              On an ILP64 platform, the following 55 byte version should work:



              f(t,s){t/=1e3;strftime(s,12,"%y%m%d.%H%M",gmtime(&t));}





              share|improve this answer











              $endgroup$













              • $begingroup$
                What's the extra s argument you're taking for?
                $endgroup$
                – Shaggy
                Jan 12 at 14:47






              • 1




                $begingroup$
                @Shaggy The s is for the output string.
                $endgroup$
                – nwellnhof
                Jan 12 at 15:06










              • $begingroup$
                It looks like you're initiating it outside the function; do we have a meta consensus that allows C to do that?
                $endgroup$
                – Shaggy
                Jan 12 at 15:31










              • $begingroup$
                @Shaggy I'm not sure what "consensus" means exactly but here's the relevant meta post.
                $endgroup$
                – nwellnhof
                Jan 12 at 15:54










              • $begingroup$
                With "32-bit,", why long long instead of long or int32_t, int64_t, time_t? IAC, all shorter than long long.
                $endgroup$
                – chux
                Jan 13 at 22:23



















              2












              $begingroup$


              Perl 6, 57 50 bytes





              {TR:d/T:-/./}o{substr ~DateTime.new($_/1e3): 2,15}


              Try it online!



              Takes the default stringification of a Datetime, in the format yyyy-mm-ddThh:mm:ssZ and modifies it to fit the output format. Perl 6 is in need of a date formatter method.



              Explanation:



                                     Datetime.new($_/1e3) # Create a date time
              ~ # Stringify it to the format yyyy-mm-ddThh:mm:ssZ
              # e.g. 2019-01-11T19:11:06.744000Z
              substr : 2,15 # Take the middle 15 characters
              {TR:d/T /./}o # Then replace 'T' with '.'
              :- # Then remove ':' and '-'





              share|improve this answer











              $endgroup$





















                2












                $begingroup$


                C# (Visual C# Interactive Compiler), 67 61 60 bytes





                n=>$"{new DateTime(1970,1,1).AddTicks(n*10000):yyMMdd.HHmm}"


                For reasons unknown to me, DateTime.UnixEpoch doesn't work.



                Try it online!






                share|improve this answer











                $endgroup$









                • 1




                  $begingroup$
                  It seems UnixEpoch is only present in.Net Core 2.1+
                  $endgroup$
                  – digEmAll
                  Jan 12 at 12:19



















                2












                $begingroup$

                Javascript ES6, 76 66 bytes



                x=>new Date(x).toJSON().slice(2,16).replace(/D/g,a=>a>'S'?'.':'')


                Try it online



                -10 bytes thanks to Shaggy!





                x // timestamp
                =>
                new Date(x) // date object from timestamp
                .toJSON() // same as .toISOString()
                .slice(2,16) // cut off excess
                .replace(/D/g, // match all non-digits
                a // a is matched character
                =>
                a>'S'?'.' // if a is T (bigger than S is shorter) replace it with .
                :'' // if it's not T, replace it with nothing
                // this way the dashes get removed and the dot gets put in the right place
                ) // end of replace





                share|improve this answer











                $endgroup$









                • 3




                  $begingroup$
                  You may want to wait a day or so before answering your own questions next time.
                  $endgroup$
                  – fəˈnɛtɪk
                  Jan 11 at 20:11










                • $begingroup$
                  71 bytes
                  $endgroup$
                  – Luis felipe De jesus Munoz
                  Jan 11 at 20:16










                • $begingroup$
                  Alternative 71 bytes
                  $endgroup$
                  – Shaggy
                  Jan 11 at 20:33






                • 1




                  $begingroup$
                  @LuisfelipeDejesusMunoz, that's different enough for you to post yourself.
                  $endgroup$
                  – Shaggy
                  Jan 11 at 21:49










                • $begingroup$
                  @LuisfelipeDejesusMunoz 66 bytes to tie you with Arnauld.
                  $endgroup$
                  – Shaggy
                  Jan 12 at 13:50



















                2












                $begingroup$


                C (clang), 117 111 bytes



                Thanks to @chux and @ceilingcat for the suggestions.





                #import<time.h>
                *l;f(long t){t/=1e3;printf("%02d%02d%02d.%02d%02d",5[l=gmtime(&t)]%100,l[4]+1,l[3],l[2],l[1]);}


                Try it online!






                share|improve this answer











                $endgroup$













                • $begingroup$
                  gmtime is short than localtime
                  $endgroup$
                  – chux
                  Jan 13 at 22:08



















                2












                $begingroup$

                Twig, 25 characters



                {{d[:-3]|date('ymd.hi')}}


                This is a template. Call it by including it and pass the Unix time as parameter d.



                Sample usage:



                {{include('datetime.twig', {'d': 1547233866744})}}


                Try it on TwigFiddle






                share|improve this answer









                $endgroup$





















                  2












                  $begingroup$

                  JavaScript, 64 bytes





                  n=>'2356891911121415'.replace(/1?./g,x=>new Date(n).toJSON()[x])


                  Try it online!






                  share|improve this answer









                  $endgroup$













                  • $begingroup$
                    aw, so close
                    $endgroup$
                    – ASCII-only
                    Jan 15 at 5:47










                  • $begingroup$
                    also 64
                    $endgroup$
                    – ASCII-only
                    Jan 15 at 5:48





















                  1












                  $begingroup$

                  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









                  $endgroup$









                  • 3




                    $begingroup$
                    You don't need to count command-line flags anymore.
                    $endgroup$
                    – AdmBorkBork
                    Jan 11 at 20:28










                  • $begingroup$
                    Oops. Good to know. Thank you @AdmBorkBork.
                    $endgroup$
                    – manatwork
                    Jan 11 at 20:36










                  • $begingroup$
                    1000 -> 1e3
                    $endgroup$
                    – Shaggy
                    Jan 14 at 20:16



















                  1












                  $begingroup$


                  ksh, 36 bytes





                  printf "%(%y%m%d.%H%M)T" $(($1/1e3))


                  Try it online!



                  Thanks to Jo King for 15 bytes saved






                  share|improve this answer











                  $endgroup$













                  • $begingroup$
                    The same in Bash would be just 35 characters: Try it online!
                    $endgroup$
                    – manatwork
                    Jan 13 at 15:25



















                  1












                  $begingroup$

                  MediaWiki, 46 bytes



                  {{#time:ymd.Hi|@{{#expr:floor({{{1}}}/1e3)}}}}





                  share|improve this answer









                  $endgroup$





















                    1












                    $begingroup$

                    Java 8, 78 bytes





                    n->new java.text.SimpleDateFormat("yyMMdd.HHmm").format(new java.util.Date(n))


                    Try it online.



                    Explanation:



                    n->                       // Method with long parameter and String return-type
                    new java.text.SimpleDateFormat("yyMMdd.HHmm")
                    // Create the formatter
                    .format( // Format the date to a String in this format and return it:
                    new java.util.Date( // Create a new Date
                    n)) // With the input-long as timestamp





                    share|improve this answer









                    $endgroup$













                      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
                      });


                      }
                      });














                      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

























                      21 Answers
                      21






                      active

                      oldest

                      votes








                      21 Answers
                      21






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes









                      3












                      $begingroup$


                      Japt v1.4.5, 19 16 bytes



                      GîÐU s3)¤o>J i.G


                      1 byte saved thanks to Oliver, which led to another 2 bytes saved.



                      Try it





                      Explanation



                      GîÐU s3)¤o>J i.G
                      :Implicit input of integer U
                      G :16
                      î :Get the first 16 characters of the following string
                      ÐU : Convert U to a date object
                      s3 : Convert to ISO string
                      ) :End get
                      ¤ :Slice off the first 2 characters
                      o :Filter
                      >J : Greater than -1
                      i.G :Insert "." at 0-based index 16, with wrapping




                      Notes / Tips




                      • Getting the first 16 characters of the ISO string and then slicing off the first two is a byte shorter than performing a single slice.


                      • G is used to insert the . at the required index because using a literal 6 would cause it to be combined with the . and for that to be interpreted as a decimal that would be inserted at the start of the string. To get around that I'd need to add a ' before the . to force it to be interpreted as a string.

                      • Japt v1.4.5 is used because Japt doesn't have a constant for 17 and from v1.4.6 on trying to insert something at the first index past the end of a string results in it being inserted at the end of the string (A is the Japt constant for 10) whereas prior to v1.4.6 it immediately wraps back to the beginning of the string.






                      share|improve this answer











                      $endgroup$


















                        3












                        $begingroup$


                        Japt v1.4.5, 19 16 bytes



                        GîÐU s3)¤o>J i.G


                        1 byte saved thanks to Oliver, which led to another 2 bytes saved.



                        Try it





                        Explanation



                        GîÐU s3)¤o>J i.G
                        :Implicit input of integer U
                        G :16
                        î :Get the first 16 characters of the following string
                        ÐU : Convert U to a date object
                        s3 : Convert to ISO string
                        ) :End get
                        ¤ :Slice off the first 2 characters
                        o :Filter
                        >J : Greater than -1
                        i.G :Insert "." at 0-based index 16, with wrapping




                        Notes / Tips




                        • Getting the first 16 characters of the ISO string and then slicing off the first two is a byte shorter than performing a single slice.


                        • G is used to insert the . at the required index because using a literal 6 would cause it to be combined with the . and for that to be interpreted as a decimal that would be inserted at the start of the string. To get around that I'd need to add a ' before the . to force it to be interpreted as a string.

                        • Japt v1.4.5 is used because Japt doesn't have a constant for 17 and from v1.4.6 on trying to insert something at the first index past the end of a string results in it being inserted at the end of the string (A is the Japt constant for 10) whereas prior to v1.4.6 it immediately wraps back to the beginning of the string.






                        share|improve this answer











                        $endgroup$
















                          3












                          3








                          3





                          $begingroup$


                          Japt v1.4.5, 19 16 bytes



                          GîÐU s3)¤o>J i.G


                          1 byte saved thanks to Oliver, which led to another 2 bytes saved.



                          Try it





                          Explanation



                          GîÐU s3)¤o>J i.G
                          :Implicit input of integer U
                          G :16
                          î :Get the first 16 characters of the following string
                          ÐU : Convert U to a date object
                          s3 : Convert to ISO string
                          ) :End get
                          ¤ :Slice off the first 2 characters
                          o :Filter
                          >J : Greater than -1
                          i.G :Insert "." at 0-based index 16, with wrapping




                          Notes / Tips




                          • Getting the first 16 characters of the ISO string and then slicing off the first two is a byte shorter than performing a single slice.


                          • G is used to insert the . at the required index because using a literal 6 would cause it to be combined with the . and for that to be interpreted as a decimal that would be inserted at the start of the string. To get around that I'd need to add a ' before the . to force it to be interpreted as a string.

                          • Japt v1.4.5 is used because Japt doesn't have a constant for 17 and from v1.4.6 on trying to insert something at the first index past the end of a string results in it being inserted at the end of the string (A is the Japt constant for 10) whereas prior to v1.4.6 it immediately wraps back to the beginning of the string.






                          share|improve this answer











                          $endgroup$




                          Japt v1.4.5, 19 16 bytes



                          GîÐU s3)¤o>J i.G


                          1 byte saved thanks to Oliver, which led to another 2 bytes saved.



                          Try it





                          Explanation



                          GîÐU s3)¤o>J i.G
                          :Implicit input of integer U
                          G :16
                          î :Get the first 16 characters of the following string
                          ÐU : Convert U to a date object
                          s3 : Convert to ISO string
                          ) :End get
                          ¤ :Slice off the first 2 characters
                          o :Filter
                          >J : Greater than -1
                          i.G :Insert "." at 0-based index 16, with wrapping




                          Notes / Tips




                          • Getting the first 16 characters of the ISO string and then slicing off the first two is a byte shorter than performing a single slice.


                          • G is used to insert the . at the required index because using a literal 6 would cause it to be combined with the . and for that to be interpreted as a decimal that would be inserted at the start of the string. To get around that I'd need to add a ' before the . to force it to be interpreted as a string.

                          • Japt v1.4.5 is used because Japt doesn't have a constant for 17 and from v1.4.6 on trying to insert something at the first index past the end of a string results in it being inserted at the end of the string (A is the Japt constant for 10) whereas prior to v1.4.6 it immediately wraps back to the beginning of the string.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Jan 14 at 18:44

























                          answered Jan 11 at 22:34









                          ShaggyShaggy

                          19.5k21666




                          19.5k21666























                              8












                              $begingroup$

                              JavaScript (ES6), 65 bytes



                              n=>'101010.1010'.replace(i=/d/g,x=>new Date(n).toJSON()[i=x-~i])


                              Try it online!



                              How?



                              We initialize the pointer $i$ to a non-numeric value (coerced to $0$) and then add alternately $2$ and $1$ to it to pick the relevant characters from the ISO-8601 conversion of the input timestamp.



                              yyyy-mm-ddThh:mm:ss.sssZ
                              ^^ ^^ ^^ ^^ ^^




                              JavaScript (ES6), 66 bytes



                              n=>'235689.BCEF'.replace(/w/g,x=>new Date(n).toJSON()[+`0x${x}`])


                              Try it online!



                              How?



                              Once the input timestamp is converted in ISO-8601 format, all required characters can be accessed with a single hexadecimal digit.



                              yyyy-mm-ddThh:mm:ss.sssZ
                              ↓↓ ↓↓ ↓↓ ↓↓ ↓↓
                              0123456789ABCDEF





                              share|improve this answer











                              $endgroup$













                              • $begingroup$
                                Wow. Just, wow.
                                $endgroup$
                                – skiilaa
                                Jan 13 at 9:08






                              • 1




                                $begingroup$
                                64 bytes: n=>'235689.11121415'.replace(/1?w/g,x=>new Date(n).toJSON()[x])
                                $endgroup$
                                – tsh
                                Jan 14 at 7:02










                              • $begingroup$
                                @tsh Nice! I was not expecting the decimal format to be shorter. You may want to post this as a separate answer.
                                $endgroup$
                                – Arnauld
                                Jan 14 at 15:45
















                              8












                              $begingroup$

                              JavaScript (ES6), 65 bytes



                              n=>'101010.1010'.replace(i=/d/g,x=>new Date(n).toJSON()[i=x-~i])


                              Try it online!



                              How?



                              We initialize the pointer $i$ to a non-numeric value (coerced to $0$) and then add alternately $2$ and $1$ to it to pick the relevant characters from the ISO-8601 conversion of the input timestamp.



                              yyyy-mm-ddThh:mm:ss.sssZ
                              ^^ ^^ ^^ ^^ ^^




                              JavaScript (ES6), 66 bytes



                              n=>'235689.BCEF'.replace(/w/g,x=>new Date(n).toJSON()[+`0x${x}`])


                              Try it online!



                              How?



                              Once the input timestamp is converted in ISO-8601 format, all required characters can be accessed with a single hexadecimal digit.



                              yyyy-mm-ddThh:mm:ss.sssZ
                              ↓↓ ↓↓ ↓↓ ↓↓ ↓↓
                              0123456789ABCDEF





                              share|improve this answer











                              $endgroup$













                              • $begingroup$
                                Wow. Just, wow.
                                $endgroup$
                                – skiilaa
                                Jan 13 at 9:08






                              • 1




                                $begingroup$
                                64 bytes: n=>'235689.11121415'.replace(/1?w/g,x=>new Date(n).toJSON()[x])
                                $endgroup$
                                – tsh
                                Jan 14 at 7:02










                              • $begingroup$
                                @tsh Nice! I was not expecting the decimal format to be shorter. You may want to post this as a separate answer.
                                $endgroup$
                                – Arnauld
                                Jan 14 at 15:45














                              8












                              8








                              8





                              $begingroup$

                              JavaScript (ES6), 65 bytes



                              n=>'101010.1010'.replace(i=/d/g,x=>new Date(n).toJSON()[i=x-~i])


                              Try it online!



                              How?



                              We initialize the pointer $i$ to a non-numeric value (coerced to $0$) and then add alternately $2$ and $1$ to it to pick the relevant characters from the ISO-8601 conversion of the input timestamp.



                              yyyy-mm-ddThh:mm:ss.sssZ
                              ^^ ^^ ^^ ^^ ^^




                              JavaScript (ES6), 66 bytes



                              n=>'235689.BCEF'.replace(/w/g,x=>new Date(n).toJSON()[+`0x${x}`])


                              Try it online!



                              How?



                              Once the input timestamp is converted in ISO-8601 format, all required characters can be accessed with a single hexadecimal digit.



                              yyyy-mm-ddThh:mm:ss.sssZ
                              ↓↓ ↓↓ ↓↓ ↓↓ ↓↓
                              0123456789ABCDEF





                              share|improve this answer











                              $endgroup$



                              JavaScript (ES6), 65 bytes



                              n=>'101010.1010'.replace(i=/d/g,x=>new Date(n).toJSON()[i=x-~i])


                              Try it online!



                              How?



                              We initialize the pointer $i$ to a non-numeric value (coerced to $0$) and then add alternately $2$ and $1$ to it to pick the relevant characters from the ISO-8601 conversion of the input timestamp.



                              yyyy-mm-ddThh:mm:ss.sssZ
                              ^^ ^^ ^^ ^^ ^^




                              JavaScript (ES6), 66 bytes



                              n=>'235689.BCEF'.replace(/w/g,x=>new Date(n).toJSON()[+`0x${x}`])


                              Try it online!



                              How?



                              Once the input timestamp is converted in ISO-8601 format, all required characters can be accessed with a single hexadecimal digit.



                              yyyy-mm-ddThh:mm:ss.sssZ
                              ↓↓ ↓↓ ↓↓ ↓↓ ↓↓
                              0123456789ABCDEF






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Jan 12 at 20:49

























                              answered Jan 12 at 10:51









                              ArnauldArnauld

                              74.1k690310




                              74.1k690310












                              • $begingroup$
                                Wow. Just, wow.
                                $endgroup$
                                – skiilaa
                                Jan 13 at 9:08






                              • 1




                                $begingroup$
                                64 bytes: n=>'235689.11121415'.replace(/1?w/g,x=>new Date(n).toJSON()[x])
                                $endgroup$
                                – tsh
                                Jan 14 at 7:02










                              • $begingroup$
                                @tsh Nice! I was not expecting the decimal format to be shorter. You may want to post this as a separate answer.
                                $endgroup$
                                – Arnauld
                                Jan 14 at 15:45


















                              • $begingroup$
                                Wow. Just, wow.
                                $endgroup$
                                – skiilaa
                                Jan 13 at 9:08






                              • 1




                                $begingroup$
                                64 bytes: n=>'235689.11121415'.replace(/1?w/g,x=>new Date(n).toJSON()[x])
                                $endgroup$
                                – tsh
                                Jan 14 at 7:02










                              • $begingroup$
                                @tsh Nice! I was not expecting the decimal format to be shorter. You may want to post this as a separate answer.
                                $endgroup$
                                – Arnauld
                                Jan 14 at 15:45
















                              $begingroup$
                              Wow. Just, wow.
                              $endgroup$
                              – skiilaa
                              Jan 13 at 9:08




                              $begingroup$
                              Wow. Just, wow.
                              $endgroup$
                              – skiilaa
                              Jan 13 at 9:08




                              1




                              1




                              $begingroup$
                              64 bytes: n=>'235689.11121415'.replace(/1?w/g,x=>new Date(n).toJSON()[x])
                              $endgroup$
                              – tsh
                              Jan 14 at 7:02




                              $begingroup$
                              64 bytes: n=>'235689.11121415'.replace(/1?w/g,x=>new Date(n).toJSON()[x])
                              $endgroup$
                              – tsh
                              Jan 14 at 7:02












                              $begingroup$
                              @tsh Nice! I was not expecting the decimal format to be shorter. You may want to post this as a separate answer.
                              $endgroup$
                              – Arnauld
                              Jan 14 at 15:45




                              $begingroup$
                              @tsh Nice! I was not expecting the decimal format to be shorter. You may want to post this as a separate answer.
                              $endgroup$
                              – Arnauld
                              Jan 14 at 15:45











                              7












                              $begingroup$


                              Bash + coreutils, 29 bytes





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


                              Try it online!






                              share|improve this answer









                              $endgroup$


















                                7












                                $begingroup$


                                Bash + coreutils, 29 bytes





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


                                Try it online!






                                share|improve this answer









                                $endgroup$
















                                  7












                                  7








                                  7





                                  $begingroup$


                                  Bash + coreutils, 29 bytes





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


                                  Try it online!






                                  share|improve this answer









                                  $endgroup$




                                  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 Jan 11 at 19:59









                                  NeilNeil

                                  80k744178




                                  80k744178























                                      6












                                      $begingroup$


                                      PHP, 40 32 31 bytes



                                      -8 bytes thanks to Luis felipe
                                      -1 byte thanks to Jo King





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


                                      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 /1e3 because date expects second-precise timestamps. This also coerces the string to a number.






                                      share|improve this answer











                                      $endgroup$













                                      • $begingroup$
                                        Nice answer! It's a tad shorter if the language has date formatting, yes :)
                                        $endgroup$
                                        – skiilaa
                                        Jan 11 at 20:03










                                      • $begingroup$
                                        32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string
                                        $endgroup$
                                        – Luis felipe De jesus Munoz
                                        Jan 11 at 20:04












                                      • $begingroup$
                                        ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P
                                        $endgroup$
                                        – Skidsdev
                                        Jan 11 at 20:08










                                      • $begingroup$
                                        @JoKing ah nice one, thanks
                                        $endgroup$
                                        – Skidsdev
                                        Jan 14 at 14:03
















                                      6












                                      $begingroup$


                                      PHP, 40 32 31 bytes



                                      -8 bytes thanks to Luis felipe
                                      -1 byte thanks to Jo King





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


                                      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 /1e3 because date expects second-precise timestamps. This also coerces the string to a number.






                                      share|improve this answer











                                      $endgroup$













                                      • $begingroup$
                                        Nice answer! It's a tad shorter if the language has date formatting, yes :)
                                        $endgroup$
                                        – skiilaa
                                        Jan 11 at 20:03










                                      • $begingroup$
                                        32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string
                                        $endgroup$
                                        – Luis felipe De jesus Munoz
                                        Jan 11 at 20:04












                                      • $begingroup$
                                        ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P
                                        $endgroup$
                                        – Skidsdev
                                        Jan 11 at 20:08










                                      • $begingroup$
                                        @JoKing ah nice one, thanks
                                        $endgroup$
                                        – Skidsdev
                                        Jan 14 at 14:03














                                      6












                                      6








                                      6





                                      $begingroup$


                                      PHP, 40 32 31 bytes



                                      -8 bytes thanks to Luis felipe
                                      -1 byte thanks to Jo King





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


                                      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 /1e3 because date expects second-precise timestamps. This also coerces the string to a number.






                                      share|improve this answer











                                      $endgroup$




                                      PHP, 40 32 31 bytes



                                      -8 bytes thanks to Luis felipe
                                      -1 byte thanks to Jo King





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


                                      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 /1e3 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 Jan 14 at 14:02

























                                      answered Jan 11 at 20:00









                                      SkidsdevSkidsdev

                                      6,4262974




                                      6,4262974












                                      • $begingroup$
                                        Nice answer! It's a tad shorter if the language has date formatting, yes :)
                                        $endgroup$
                                        – skiilaa
                                        Jan 11 at 20:03










                                      • $begingroup$
                                        32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string
                                        $endgroup$
                                        – Luis felipe De jesus Munoz
                                        Jan 11 at 20:04












                                      • $begingroup$
                                        ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P
                                        $endgroup$
                                        – Skidsdev
                                        Jan 11 at 20:08










                                      • $begingroup$
                                        @JoKing ah nice one, thanks
                                        $endgroup$
                                        – Skidsdev
                                        Jan 14 at 14:03


















                                      • $begingroup$
                                        Nice answer! It's a tad shorter if the language has date formatting, yes :)
                                        $endgroup$
                                        – skiilaa
                                        Jan 11 at 20:03










                                      • $begingroup$
                                        32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string
                                        $endgroup$
                                        – Luis felipe De jesus Munoz
                                        Jan 11 at 20:04












                                      • $begingroup$
                                        ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P
                                        $endgroup$
                                        – Skidsdev
                                        Jan 11 at 20:08










                                      • $begingroup$
                                        @JoKing ah nice one, thanks
                                        $endgroup$
                                        – Skidsdev
                                        Jan 14 at 14:03
















                                      $begingroup$
                                      Nice answer! It's a tad shorter if the language has date formatting, yes :)
                                      $endgroup$
                                      – skiilaa
                                      Jan 11 at 20:03




                                      $begingroup$
                                      Nice answer! It's a tad shorter if the language has date formatting, yes :)
                                      $endgroup$
                                      – skiilaa
                                      Jan 11 at 20:03












                                      $begingroup$
                                      32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string
                                      $endgroup$
                                      – Luis felipe De jesus Munoz
                                      Jan 11 at 20:04






                                      $begingroup$
                                      32 bytes you dont need to cast to integer since "2"/1 will cast automatically the string
                                      $endgroup$
                                      – Luis felipe De jesus Munoz
                                      Jan 11 at 20:04














                                      $begingroup$
                                      ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P
                                      $endgroup$
                                      – Skidsdev
                                      Jan 11 at 20:08




                                      $begingroup$
                                      ah of course, I added intval before realising I needed /1000, and didn't think that I mihgt not need it afterwards :P
                                      $endgroup$
                                      – Skidsdev
                                      Jan 11 at 20:08












                                      $begingroup$
                                      @JoKing ah nice one, thanks
                                      $endgroup$
                                      – Skidsdev
                                      Jan 14 at 14:03




                                      $begingroup$
                                      @JoKing ah nice one, thanks
                                      $endgroup$
                                      – Skidsdev
                                      Jan 14 at 14:03











                                      5












                                      $begingroup$


                                      MATL, 28 bytes



                                      Thanks to @skiilaa for a correction in the output format.



                                      864e5/719529+'YYmmDD.HHMM'XO


                                      Try it online!



                                      Explanation



                                      MATL, like MATLAB, defines date/time numbers as the (possibly non-integer) number of days since time 00:00 of the reference "date" 0-Jan-0000.



                                      Thus we take the input, divide it by 86400000 (number of milliseconds in one day), add 719529 (number of days from MATL's reference to UNIX reference), and convert to the desired format 'YYmmDD.HHMM'.






                                      share|improve this answer











                                      $endgroup$


















                                        5












                                        $begingroup$


                                        MATL, 28 bytes



                                        Thanks to @skiilaa for a correction in the output format.



                                        864e5/719529+'YYmmDD.HHMM'XO


                                        Try it online!



                                        Explanation



                                        MATL, like MATLAB, defines date/time numbers as the (possibly non-integer) number of days since time 00:00 of the reference "date" 0-Jan-0000.



                                        Thus we take the input, divide it by 86400000 (number of milliseconds in one day), add 719529 (number of days from MATL's reference to UNIX reference), and convert to the desired format 'YYmmDD.HHMM'.






                                        share|improve this answer











                                        $endgroup$
















                                          5












                                          5








                                          5





                                          $begingroup$


                                          MATL, 28 bytes



                                          Thanks to @skiilaa for a correction in the output format.



                                          864e5/719529+'YYmmDD.HHMM'XO


                                          Try it online!



                                          Explanation



                                          MATL, like MATLAB, defines date/time numbers as the (possibly non-integer) number of days since time 00:00 of the reference "date" 0-Jan-0000.



                                          Thus we take the input, divide it by 86400000 (number of milliseconds in one day), add 719529 (number of days from MATL's reference to UNIX reference), and convert to the desired format 'YYmmDD.HHMM'.






                                          share|improve this answer











                                          $endgroup$




                                          MATL, 28 bytes



                                          Thanks to @skiilaa for a correction in the output format.



                                          864e5/719529+'YYmmDD.HHMM'XO


                                          Try it online!



                                          Explanation



                                          MATL, like MATLAB, defines date/time numbers as the (possibly non-integer) number of days since time 00:00 of the reference "date" 0-Jan-0000.



                                          Thus we take the input, divide it by 86400000 (number of milliseconds in one day), add 719529 (number of days from MATL's reference to UNIX reference), and convert to the desired format 'YYmmDD.HHMM'.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited Jan 13 at 16:06

























                                          answered Jan 11 at 22:00









                                          Luis MendoLuis Mendo

                                          74.2k887291




                                          74.2k887291























                                              4












                                              $begingroup$

                                              GNU AWK, 34 33 characters



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


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



                                              Thanks to:





                                              • Jo King for suggesting E-notation (-1 character)


                                              Sampler run:



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


                                              Try it online!






                                              share|improve this answer











                                              $endgroup$













                                              • $begingroup$
                                                Thank you, @JoKing. Unfortunately E-notation is not really my friend so I always forget it.
                                                $endgroup$
                                                – manatwork
                                                Jan 13 at 16:02
















                                              4












                                              $begingroup$

                                              GNU AWK, 34 33 characters



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


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



                                              Thanks to:





                                              • Jo King for suggesting E-notation (-1 character)


                                              Sampler run:



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


                                              Try it online!






                                              share|improve this answer











                                              $endgroup$













                                              • $begingroup$
                                                Thank you, @JoKing. Unfortunately E-notation is not really my friend so I always forget it.
                                                $endgroup$
                                                – manatwork
                                                Jan 13 at 16:02














                                              4












                                              4








                                              4





                                              $begingroup$

                                              GNU AWK, 34 33 characters



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


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



                                              Thanks to:





                                              • Jo King for suggesting E-notation (-1 character)


                                              Sampler run:



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


                                              Try it online!






                                              share|improve this answer











                                              $endgroup$



                                              GNU AWK, 34 33 characters



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


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



                                              Thanks to:





                                              • Jo King for suggesting E-notation (-1 character)


                                              Sampler run:



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


                                              Try it online!







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited Jan 13 at 16:05

























                                              answered Jan 11 at 20:28









                                              manatworkmanatwork

                                              16.3k43572




                                              16.3k43572












                                              • $begingroup$
                                                Thank you, @JoKing. Unfortunately E-notation is not really my friend so I always forget it.
                                                $endgroup$
                                                – manatwork
                                                Jan 13 at 16:02


















                                              • $begingroup$
                                                Thank you, @JoKing. Unfortunately E-notation is not really my friend so I always forget it.
                                                $endgroup$
                                                – manatwork
                                                Jan 13 at 16:02
















                                              $begingroup$
                                              Thank you, @JoKing. Unfortunately E-notation is not really my friend so I always forget it.
                                              $endgroup$
                                              – manatwork
                                              Jan 13 at 16:02




                                              $begingroup$
                                              Thank you, @JoKing. Unfortunately E-notation is not really my friend so I always forget it.
                                              $endgroup$
                                              – manatwork
                                              Jan 13 at 16:02











                                              4












                                              $begingroup$


                                              PowerShell, 59 58 bytes





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


                                              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.



                                              -1 byte thanks to shaggy.






                                              share|improve this answer











                                              $endgroup$


















                                                4












                                                $begingroup$


                                                PowerShell, 59 58 bytes





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


                                                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.



                                                -1 byte thanks to shaggy.






                                                share|improve this answer











                                                $endgroup$
















                                                  4












                                                  4








                                                  4





                                                  $begingroup$


                                                  PowerShell, 59 58 bytes





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


                                                  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.



                                                  -1 byte thanks to shaggy.






                                                  share|improve this answer











                                                  $endgroup$




                                                  PowerShell, 59 58 bytes





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


                                                  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.



                                                  -1 byte thanks to shaggy.







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited Jan 14 at 13:39

























                                                  answered Jan 11 at 20:15









                                                  AdmBorkBorkAdmBorkBork

                                                  26.6k364229




                                                  26.6k364229























                                                      3












                                                      $begingroup$


                                                      Perl 6,  111 89  87 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)



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


                                                      Try it (87)



                                                      Explanation:



                                                      The o infix operator takes two functions and creates a composite function. The rightmost one gets called first, and the one to the left gets called with its result.



                                                      Basically we use 4 block lambdas to generate a single lambda.



                                                      Which is not much different to how a WhateverCode lambda like * + * gets created.





                                                      Divide by 1000 and use that to create a DateTime object.



                                                      {DateTime.new($_/Ⅿ)} # Ⅿ is ROMAN NUMERAL ONE THOUSAND (3 bytes)


                                                      The result gets used by:



                                                      {
                                                      .yyyy-mm-dd # 2019-01-11

                                                      ~ '.' ~ # str concatenation with '.'

                                                      ( .hour, .minute ).fmt('%02d') # add leading 0s (returns List)
                                                      }


                                                      That leaves us with a string like 2019-01-11.19 11



                                                      We need to remove the first two digits



                                                      {S/..//}


                                                      We also need to remove - and



                                                      {TR/- //}





                                                      share|improve this answer











                                                      $endgroup$


















                                                        3












                                                        $begingroup$


                                                        Perl 6,  111 89  87 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)



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


                                                        Try it (87)



                                                        Explanation:



                                                        The o infix operator takes two functions and creates a composite function. The rightmost one gets called first, and the one to the left gets called with its result.



                                                        Basically we use 4 block lambdas to generate a single lambda.



                                                        Which is not much different to how a WhateverCode lambda like * + * gets created.





                                                        Divide by 1000 and use that to create a DateTime object.



                                                        {DateTime.new($_/Ⅿ)} # Ⅿ is ROMAN NUMERAL ONE THOUSAND (3 bytes)


                                                        The result gets used by:



                                                        {
                                                        .yyyy-mm-dd # 2019-01-11

                                                        ~ '.' ~ # str concatenation with '.'

                                                        ( .hour, .minute ).fmt('%02d') # add leading 0s (returns List)
                                                        }


                                                        That leaves us with a string like 2019-01-11.19 11



                                                        We need to remove the first two digits



                                                        {S/..//}


                                                        We also need to remove - and



                                                        {TR/- //}





                                                        share|improve this answer











                                                        $endgroup$
















                                                          3












                                                          3








                                                          3





                                                          $begingroup$


                                                          Perl 6,  111 89  87 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)



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


                                                          Try it (87)



                                                          Explanation:



                                                          The o infix operator takes two functions and creates a composite function. The rightmost one gets called first, and the one to the left gets called with its result.



                                                          Basically we use 4 block lambdas to generate a single lambda.



                                                          Which is not much different to how a WhateverCode lambda like * + * gets created.





                                                          Divide by 1000 and use that to create a DateTime object.



                                                          {DateTime.new($_/Ⅿ)} # Ⅿ is ROMAN NUMERAL ONE THOUSAND (3 bytes)


                                                          The result gets used by:



                                                          {
                                                          .yyyy-mm-dd # 2019-01-11

                                                          ~ '.' ~ # str concatenation with '.'

                                                          ( .hour, .minute ).fmt('%02d') # add leading 0s (returns List)
                                                          }


                                                          That leaves us with a string like 2019-01-11.19 11



                                                          We need to remove the first two digits



                                                          {S/..//}


                                                          We also need to remove - and



                                                          {TR/- //}





                                                          share|improve this answer











                                                          $endgroup$




                                                          Perl 6,  111 89  87 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)



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


                                                          Try it (87)



                                                          Explanation:



                                                          The o infix operator takes two functions and creates a composite function. The rightmost one gets called first, and the one to the left gets called with its result.



                                                          Basically we use 4 block lambdas to generate a single lambda.



                                                          Which is not much different to how a WhateverCode lambda like * + * gets created.





                                                          Divide by 1000 and use that to create a DateTime object.



                                                          {DateTime.new($_/Ⅿ)} # Ⅿ is ROMAN NUMERAL ONE THOUSAND (3 bytes)


                                                          The result gets used by:



                                                          {
                                                          .yyyy-mm-dd # 2019-01-11

                                                          ~ '.' ~ # str concatenation with '.'

                                                          ( .hour, .minute ).fmt('%02d') # add leading 0s (returns List)
                                                          }


                                                          That leaves us with a string like 2019-01-11.19 11



                                                          We need to remove the first two digits



                                                          {S/..//}


                                                          We also need to remove - and



                                                          {TR/- //}






                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited Jan 11 at 21:37

























                                                          answered Jan 11 at 20:46









                                                          Brad Gilbert b2gillsBrad Gilbert b2gills

                                                          12.2k11232




                                                          12.2k11232























                                                              3












                                                              $begingroup$


                                                              Python 2, 64 bytes





                                                              lambda s:strftime('%y%m%d.%H%M',gmtime(s/1e3))
                                                              from time import*


                                                              Try it online!



                                                              The input is considered to be in UTC.






                                                              share|improve this answer











                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                Just as something I've been a bit confused on, is the only reason that the lambda comes before the import because it works better for TIO's header?
                                                                $endgroup$
                                                                – Neil A.
                                                                Jan 11 at 22:43






                                                              • 2




                                                                $begingroup$
                                                                @NeilA. Yes. The import can go either before or after, the contents of the lambda aren't checked for NameErrors before it's called.
                                                                $endgroup$
                                                                – Erik the Outgolfer
                                                                Jan 11 at 22:45
















                                                              3












                                                              $begingroup$


                                                              Python 2, 64 bytes





                                                              lambda s:strftime('%y%m%d.%H%M',gmtime(s/1e3))
                                                              from time import*


                                                              Try it online!



                                                              The input is considered to be in UTC.






                                                              share|improve this answer











                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                Just as something I've been a bit confused on, is the only reason that the lambda comes before the import because it works better for TIO's header?
                                                                $endgroup$
                                                                – Neil A.
                                                                Jan 11 at 22:43






                                                              • 2




                                                                $begingroup$
                                                                @NeilA. Yes. The import can go either before or after, the contents of the lambda aren't checked for NameErrors before it's called.
                                                                $endgroup$
                                                                – Erik the Outgolfer
                                                                Jan 11 at 22:45














                                                              3












                                                              3








                                                              3





                                                              $begingroup$


                                                              Python 2, 64 bytes





                                                              lambda s:strftime('%y%m%d.%H%M',gmtime(s/1e3))
                                                              from time import*


                                                              Try it online!



                                                              The input is considered to be in UTC.






                                                              share|improve this answer











                                                              $endgroup$




                                                              Python 2, 64 bytes





                                                              lambda s:strftime('%y%m%d.%H%M',gmtime(s/1e3))
                                                              from time import*


                                                              Try it online!



                                                              The input is considered to be in UTC.







                                                              share|improve this answer














                                                              share|improve this answer



                                                              share|improve this answer








                                                              edited Jan 11 at 22:01

























                                                              answered Jan 11 at 21:55









                                                              Erik the OutgolferErik the Outgolfer

                                                              31.6k429103




                                                              31.6k429103








                                                              • 1




                                                                $begingroup$
                                                                Just as something I've been a bit confused on, is the only reason that the lambda comes before the import because it works better for TIO's header?
                                                                $endgroup$
                                                                – Neil A.
                                                                Jan 11 at 22:43






                                                              • 2




                                                                $begingroup$
                                                                @NeilA. Yes. The import can go either before or after, the contents of the lambda aren't checked for NameErrors before it's called.
                                                                $endgroup$
                                                                – Erik the Outgolfer
                                                                Jan 11 at 22:45














                                                              • 1




                                                                $begingroup$
                                                                Just as something I've been a bit confused on, is the only reason that the lambda comes before the import because it works better for TIO's header?
                                                                $endgroup$
                                                                – Neil A.
                                                                Jan 11 at 22:43






                                                              • 2




                                                                $begingroup$
                                                                @NeilA. Yes. The import can go either before or after, the contents of the lambda aren't checked for NameErrors before it's called.
                                                                $endgroup$
                                                                – Erik the Outgolfer
                                                                Jan 11 at 22:45








                                                              1




                                                              1




                                                              $begingroup$
                                                              Just as something I've been a bit confused on, is the only reason that the lambda comes before the import because it works better for TIO's header?
                                                              $endgroup$
                                                              – Neil A.
                                                              Jan 11 at 22:43




                                                              $begingroup$
                                                              Just as something I've been a bit confused on, is the only reason that the lambda comes before the import because it works better for TIO's header?
                                                              $endgroup$
                                                              – Neil A.
                                                              Jan 11 at 22:43




                                                              2




                                                              2




                                                              $begingroup$
                                                              @NeilA. Yes. The import can go either before or after, the contents of the lambda aren't checked for NameErrors before it's called.
                                                              $endgroup$
                                                              – Erik the Outgolfer
                                                              Jan 11 at 22:45




                                                              $begingroup$
                                                              @NeilA. Yes. The import can go either before or after, the contents of the lambda aren't checked for NameErrors before it's called.
                                                              $endgroup$
                                                              – Erik the Outgolfer
                                                              Jan 11 at 22:45











                                                              3












                                                              $begingroup$


                                                              R, 58 56 bytes





                                                              format(as.POSIXct(scan()/1e3,,'1970-1-1'),'%y%m%d.%H%M')


                                                              Try it online!






                                                              share|improve this answer











                                                              $endgroup$


















                                                                3












                                                                $begingroup$


                                                                R, 58 56 bytes





                                                                format(as.POSIXct(scan()/1e3,,'1970-1-1'),'%y%m%d.%H%M')


                                                                Try it online!






                                                                share|improve this answer











                                                                $endgroup$
















                                                                  3












                                                                  3








                                                                  3





                                                                  $begingroup$


                                                                  R, 58 56 bytes





                                                                  format(as.POSIXct(scan()/1e3,,'1970-1-1'),'%y%m%d.%H%M')


                                                                  Try it online!






                                                                  share|improve this answer











                                                                  $endgroup$




                                                                  R, 58 56 bytes





                                                                  format(as.POSIXct(scan()/1e3,,'1970-1-1'),'%y%m%d.%H%M')


                                                                  Try it online!







                                                                  share|improve this answer














                                                                  share|improve this answer



                                                                  share|improve this answer








                                                                  edited Jan 12 at 12:03

























                                                                  answered Jan 12 at 11:22









                                                                  digEmAlldigEmAll

                                                                  3,029414




                                                                  3,029414























                                                                      3












                                                                      $begingroup$


                                                                      C (gcc) (32-bit, little endian), 67 bytes





                                                                      f(t,s)long long t;{t/=1e3;strftime(s,12,"%y%m%d.%H%M",gmtime(&t));}


                                                                      Try it online!



                                                                      On an ILP64 platform, the following 55 byte version should work:



                                                                      f(t,s){t/=1e3;strftime(s,12,"%y%m%d.%H%M",gmtime(&t));}





                                                                      share|improve this answer











                                                                      $endgroup$













                                                                      • $begingroup$
                                                                        What's the extra s argument you're taking for?
                                                                        $endgroup$
                                                                        – Shaggy
                                                                        Jan 12 at 14:47






                                                                      • 1




                                                                        $begingroup$
                                                                        @Shaggy The s is for the output string.
                                                                        $endgroup$
                                                                        – nwellnhof
                                                                        Jan 12 at 15:06










                                                                      • $begingroup$
                                                                        It looks like you're initiating it outside the function; do we have a meta consensus that allows C to do that?
                                                                        $endgroup$
                                                                        – Shaggy
                                                                        Jan 12 at 15:31










                                                                      • $begingroup$
                                                                        @Shaggy I'm not sure what "consensus" means exactly but here's the relevant meta post.
                                                                        $endgroup$
                                                                        – nwellnhof
                                                                        Jan 12 at 15:54










                                                                      • $begingroup$
                                                                        With "32-bit,", why long long instead of long or int32_t, int64_t, time_t? IAC, all shorter than long long.
                                                                        $endgroup$
                                                                        – chux
                                                                        Jan 13 at 22:23
















                                                                      3












                                                                      $begingroup$


                                                                      C (gcc) (32-bit, little endian), 67 bytes





                                                                      f(t,s)long long t;{t/=1e3;strftime(s,12,"%y%m%d.%H%M",gmtime(&t));}


                                                                      Try it online!



                                                                      On an ILP64 platform, the following 55 byte version should work:



                                                                      f(t,s){t/=1e3;strftime(s,12,"%y%m%d.%H%M",gmtime(&t));}





                                                                      share|improve this answer











                                                                      $endgroup$













                                                                      • $begingroup$
                                                                        What's the extra s argument you're taking for?
                                                                        $endgroup$
                                                                        – Shaggy
                                                                        Jan 12 at 14:47






                                                                      • 1




                                                                        $begingroup$
                                                                        @Shaggy The s is for the output string.
                                                                        $endgroup$
                                                                        – nwellnhof
                                                                        Jan 12 at 15:06










                                                                      • $begingroup$
                                                                        It looks like you're initiating it outside the function; do we have a meta consensus that allows C to do that?
                                                                        $endgroup$
                                                                        – Shaggy
                                                                        Jan 12 at 15:31










                                                                      • $begingroup$
                                                                        @Shaggy I'm not sure what "consensus" means exactly but here's the relevant meta post.
                                                                        $endgroup$
                                                                        – nwellnhof
                                                                        Jan 12 at 15:54










                                                                      • $begingroup$
                                                                        With "32-bit,", why long long instead of long or int32_t, int64_t, time_t? IAC, all shorter than long long.
                                                                        $endgroup$
                                                                        – chux
                                                                        Jan 13 at 22:23














                                                                      3












                                                                      3








                                                                      3





                                                                      $begingroup$


                                                                      C (gcc) (32-bit, little endian), 67 bytes





                                                                      f(t,s)long long t;{t/=1e3;strftime(s,12,"%y%m%d.%H%M",gmtime(&t));}


                                                                      Try it online!



                                                                      On an ILP64 platform, the following 55 byte version should work:



                                                                      f(t,s){t/=1e3;strftime(s,12,"%y%m%d.%H%M",gmtime(&t));}





                                                                      share|improve this answer











                                                                      $endgroup$




                                                                      C (gcc) (32-bit, little endian), 67 bytes





                                                                      f(t,s)long long t;{t/=1e3;strftime(s,12,"%y%m%d.%H%M",gmtime(&t));}


                                                                      Try it online!



                                                                      On an ILP64 platform, the following 55 byte version should work:



                                                                      f(t,s){t/=1e3;strftime(s,12,"%y%m%d.%H%M",gmtime(&t));}






                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited Jan 12 at 15:08

























                                                                      answered Jan 12 at 14:32









                                                                      nwellnhofnwellnhof

                                                                      6,67511126




                                                                      6,67511126












                                                                      • $begingroup$
                                                                        What's the extra s argument you're taking for?
                                                                        $endgroup$
                                                                        – Shaggy
                                                                        Jan 12 at 14:47






                                                                      • 1




                                                                        $begingroup$
                                                                        @Shaggy The s is for the output string.
                                                                        $endgroup$
                                                                        – nwellnhof
                                                                        Jan 12 at 15:06










                                                                      • $begingroup$
                                                                        It looks like you're initiating it outside the function; do we have a meta consensus that allows C to do that?
                                                                        $endgroup$
                                                                        – Shaggy
                                                                        Jan 12 at 15:31










                                                                      • $begingroup$
                                                                        @Shaggy I'm not sure what "consensus" means exactly but here's the relevant meta post.
                                                                        $endgroup$
                                                                        – nwellnhof
                                                                        Jan 12 at 15:54










                                                                      • $begingroup$
                                                                        With "32-bit,", why long long instead of long or int32_t, int64_t, time_t? IAC, all shorter than long long.
                                                                        $endgroup$
                                                                        – chux
                                                                        Jan 13 at 22:23


















                                                                      • $begingroup$
                                                                        What's the extra s argument you're taking for?
                                                                        $endgroup$
                                                                        – Shaggy
                                                                        Jan 12 at 14:47






                                                                      • 1




                                                                        $begingroup$
                                                                        @Shaggy The s is for the output string.
                                                                        $endgroup$
                                                                        – nwellnhof
                                                                        Jan 12 at 15:06










                                                                      • $begingroup$
                                                                        It looks like you're initiating it outside the function; do we have a meta consensus that allows C to do that?
                                                                        $endgroup$
                                                                        – Shaggy
                                                                        Jan 12 at 15:31










                                                                      • $begingroup$
                                                                        @Shaggy I'm not sure what "consensus" means exactly but here's the relevant meta post.
                                                                        $endgroup$
                                                                        – nwellnhof
                                                                        Jan 12 at 15:54










                                                                      • $begingroup$
                                                                        With "32-bit,", why long long instead of long or int32_t, int64_t, time_t? IAC, all shorter than long long.
                                                                        $endgroup$
                                                                        – chux
                                                                        Jan 13 at 22:23
















                                                                      $begingroup$
                                                                      What's the extra s argument you're taking for?
                                                                      $endgroup$
                                                                      – Shaggy
                                                                      Jan 12 at 14:47




                                                                      $begingroup$
                                                                      What's the extra s argument you're taking for?
                                                                      $endgroup$
                                                                      – Shaggy
                                                                      Jan 12 at 14:47




                                                                      1




                                                                      1




                                                                      $begingroup$
                                                                      @Shaggy The s is for the output string.
                                                                      $endgroup$
                                                                      – nwellnhof
                                                                      Jan 12 at 15:06




                                                                      $begingroup$
                                                                      @Shaggy The s is for the output string.
                                                                      $endgroup$
                                                                      – nwellnhof
                                                                      Jan 12 at 15:06












                                                                      $begingroup$
                                                                      It looks like you're initiating it outside the function; do we have a meta consensus that allows C to do that?
                                                                      $endgroup$
                                                                      – Shaggy
                                                                      Jan 12 at 15:31




                                                                      $begingroup$
                                                                      It looks like you're initiating it outside the function; do we have a meta consensus that allows C to do that?
                                                                      $endgroup$
                                                                      – Shaggy
                                                                      Jan 12 at 15:31












                                                                      $begingroup$
                                                                      @Shaggy I'm not sure what "consensus" means exactly but here's the relevant meta post.
                                                                      $endgroup$
                                                                      – nwellnhof
                                                                      Jan 12 at 15:54




                                                                      $begingroup$
                                                                      @Shaggy I'm not sure what "consensus" means exactly but here's the relevant meta post.
                                                                      $endgroup$
                                                                      – nwellnhof
                                                                      Jan 12 at 15:54












                                                                      $begingroup$
                                                                      With "32-bit,", why long long instead of long or int32_t, int64_t, time_t? IAC, all shorter than long long.
                                                                      $endgroup$
                                                                      – chux
                                                                      Jan 13 at 22:23




                                                                      $begingroup$
                                                                      With "32-bit,", why long long instead of long or int32_t, int64_t, time_t? IAC, all shorter than long long.
                                                                      $endgroup$
                                                                      – chux
                                                                      Jan 13 at 22:23











                                                                      2












                                                                      $begingroup$


                                                                      Perl 6, 57 50 bytes





                                                                      {TR:d/T:-/./}o{substr ~DateTime.new($_/1e3): 2,15}


                                                                      Try it online!



                                                                      Takes the default stringification of a Datetime, in the format yyyy-mm-ddThh:mm:ssZ and modifies it to fit the output format. Perl 6 is in need of a date formatter method.



                                                                      Explanation:



                                                                                             Datetime.new($_/1e3) # Create a date time
                                                                      ~ # Stringify it to the format yyyy-mm-ddThh:mm:ssZ
                                                                      # e.g. 2019-01-11T19:11:06.744000Z
                                                                      substr : 2,15 # Take the middle 15 characters
                                                                      {TR:d/T /./}o # Then replace 'T' with '.'
                                                                      :- # Then remove ':' and '-'





                                                                      share|improve this answer











                                                                      $endgroup$


















                                                                        2












                                                                        $begingroup$


                                                                        Perl 6, 57 50 bytes





                                                                        {TR:d/T:-/./}o{substr ~DateTime.new($_/1e3): 2,15}


                                                                        Try it online!



                                                                        Takes the default stringification of a Datetime, in the format yyyy-mm-ddThh:mm:ssZ and modifies it to fit the output format. Perl 6 is in need of a date formatter method.



                                                                        Explanation:



                                                                                               Datetime.new($_/1e3) # Create a date time
                                                                        ~ # Stringify it to the format yyyy-mm-ddThh:mm:ssZ
                                                                        # e.g. 2019-01-11T19:11:06.744000Z
                                                                        substr : 2,15 # Take the middle 15 characters
                                                                        {TR:d/T /./}o # Then replace 'T' with '.'
                                                                        :- # Then remove ':' and '-'





                                                                        share|improve this answer











                                                                        $endgroup$
















                                                                          2












                                                                          2








                                                                          2





                                                                          $begingroup$


                                                                          Perl 6, 57 50 bytes





                                                                          {TR:d/T:-/./}o{substr ~DateTime.new($_/1e3): 2,15}


                                                                          Try it online!



                                                                          Takes the default stringification of a Datetime, in the format yyyy-mm-ddThh:mm:ssZ and modifies it to fit the output format. Perl 6 is in need of a date formatter method.



                                                                          Explanation:



                                                                                                 Datetime.new($_/1e3) # Create a date time
                                                                          ~ # Stringify it to the format yyyy-mm-ddThh:mm:ssZ
                                                                          # e.g. 2019-01-11T19:11:06.744000Z
                                                                          substr : 2,15 # Take the middle 15 characters
                                                                          {TR:d/T /./}o # Then replace 'T' with '.'
                                                                          :- # Then remove ':' and '-'





                                                                          share|improve this answer











                                                                          $endgroup$




                                                                          Perl 6, 57 50 bytes





                                                                          {TR:d/T:-/./}o{substr ~DateTime.new($_/1e3): 2,15}


                                                                          Try it online!



                                                                          Takes the default stringification of a Datetime, in the format yyyy-mm-ddThh:mm:ssZ and modifies it to fit the output format. Perl 6 is in need of a date formatter method.



                                                                          Explanation:



                                                                                                 Datetime.new($_/1e3) # Create a date time
                                                                          ~ # Stringify it to the format yyyy-mm-ddThh:mm:ssZ
                                                                          # e.g. 2019-01-11T19:11:06.744000Z
                                                                          substr : 2,15 # Take the middle 15 characters
                                                                          {TR:d/T /./}o # Then replace 'T' with '.'
                                                                          :- # Then remove ':' and '-'






                                                                          share|improve this answer














                                                                          share|improve this answer



                                                                          share|improve this answer








                                                                          edited Jan 11 at 23:38

























                                                                          answered Jan 11 at 22:50









                                                                          Jo KingJo King

                                                                          21.5k248110




                                                                          21.5k248110























                                                                              2












                                                                              $begingroup$


                                                                              C# (Visual C# Interactive Compiler), 67 61 60 bytes





                                                                              n=>$"{new DateTime(1970,1,1).AddTicks(n*10000):yyMMdd.HHmm}"


                                                                              For reasons unknown to me, DateTime.UnixEpoch doesn't work.



                                                                              Try it online!






                                                                              share|improve this answer











                                                                              $endgroup$









                                                                              • 1




                                                                                $begingroup$
                                                                                It seems UnixEpoch is only present in.Net Core 2.1+
                                                                                $endgroup$
                                                                                – digEmAll
                                                                                Jan 12 at 12:19
















                                                                              2












                                                                              $begingroup$


                                                                              C# (Visual C# Interactive Compiler), 67 61 60 bytes





                                                                              n=>$"{new DateTime(1970,1,1).AddTicks(n*10000):yyMMdd.HHmm}"


                                                                              For reasons unknown to me, DateTime.UnixEpoch doesn't work.



                                                                              Try it online!






                                                                              share|improve this answer











                                                                              $endgroup$









                                                                              • 1




                                                                                $begingroup$
                                                                                It seems UnixEpoch is only present in.Net Core 2.1+
                                                                                $endgroup$
                                                                                – digEmAll
                                                                                Jan 12 at 12:19














                                                                              2












                                                                              2








                                                                              2





                                                                              $begingroup$


                                                                              C# (Visual C# Interactive Compiler), 67 61 60 bytes





                                                                              n=>$"{new DateTime(1970,1,1).AddTicks(n*10000):yyMMdd.HHmm}"


                                                                              For reasons unknown to me, DateTime.UnixEpoch doesn't work.



                                                                              Try it online!






                                                                              share|improve this answer











                                                                              $endgroup$




                                                                              C# (Visual C# Interactive Compiler), 67 61 60 bytes





                                                                              n=>$"{new DateTime(1970,1,1).AddTicks(n*10000):yyMMdd.HHmm}"


                                                                              For reasons unknown to me, DateTime.UnixEpoch doesn't work.



                                                                              Try it online!







                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited Jan 12 at 4:11

























                                                                              answered Jan 11 at 22:41









                                                                              Embodiment of IgnoranceEmbodiment of Ignorance

                                                                              721116




                                                                              721116








                                                                              • 1




                                                                                $begingroup$
                                                                                It seems UnixEpoch is only present in.Net Core 2.1+
                                                                                $endgroup$
                                                                                – digEmAll
                                                                                Jan 12 at 12:19














                                                                              • 1




                                                                                $begingroup$
                                                                                It seems UnixEpoch is only present in.Net Core 2.1+
                                                                                $endgroup$
                                                                                – digEmAll
                                                                                Jan 12 at 12:19








                                                                              1




                                                                              1




                                                                              $begingroup$
                                                                              It seems UnixEpoch is only present in.Net Core 2.1+
                                                                              $endgroup$
                                                                              – digEmAll
                                                                              Jan 12 at 12:19




                                                                              $begingroup$
                                                                              It seems UnixEpoch is only present in.Net Core 2.1+
                                                                              $endgroup$
                                                                              – digEmAll
                                                                              Jan 12 at 12:19











                                                                              2












                                                                              $begingroup$

                                                                              Javascript ES6, 76 66 bytes



                                                                              x=>new Date(x).toJSON().slice(2,16).replace(/D/g,a=>a>'S'?'.':'')


                                                                              Try it online



                                                                              -10 bytes thanks to Shaggy!





                                                                              x // timestamp
                                                                              =>
                                                                              new Date(x) // date object from timestamp
                                                                              .toJSON() // same as .toISOString()
                                                                              .slice(2,16) // cut off excess
                                                                              .replace(/D/g, // match all non-digits
                                                                              a // a is matched character
                                                                              =>
                                                                              a>'S'?'.' // if a is T (bigger than S is shorter) replace it with .
                                                                              :'' // if it's not T, replace it with nothing
                                                                              // this way the dashes get removed and the dot gets put in the right place
                                                                              ) // end of replace





                                                                              share|improve this answer











                                                                              $endgroup$









                                                                              • 3




                                                                                $begingroup$
                                                                                You may want to wait a day or so before answering your own questions next time.
                                                                                $endgroup$
                                                                                – fəˈnɛtɪk
                                                                                Jan 11 at 20:11










                                                                              • $begingroup$
                                                                                71 bytes
                                                                                $endgroup$
                                                                                – Luis felipe De jesus Munoz
                                                                                Jan 11 at 20:16










                                                                              • $begingroup$
                                                                                Alternative 71 bytes
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 11 at 20:33






                                                                              • 1




                                                                                $begingroup$
                                                                                @LuisfelipeDejesusMunoz, that's different enough for you to post yourself.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 11 at 21:49










                                                                              • $begingroup$
                                                                                @LuisfelipeDejesusMunoz 66 bytes to tie you with Arnauld.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 12 at 13:50
















                                                                              2












                                                                              $begingroup$

                                                                              Javascript ES6, 76 66 bytes



                                                                              x=>new Date(x).toJSON().slice(2,16).replace(/D/g,a=>a>'S'?'.':'')


                                                                              Try it online



                                                                              -10 bytes thanks to Shaggy!





                                                                              x // timestamp
                                                                              =>
                                                                              new Date(x) // date object from timestamp
                                                                              .toJSON() // same as .toISOString()
                                                                              .slice(2,16) // cut off excess
                                                                              .replace(/D/g, // match all non-digits
                                                                              a // a is matched character
                                                                              =>
                                                                              a>'S'?'.' // if a is T (bigger than S is shorter) replace it with .
                                                                              :'' // if it's not T, replace it with nothing
                                                                              // this way the dashes get removed and the dot gets put in the right place
                                                                              ) // end of replace





                                                                              share|improve this answer











                                                                              $endgroup$









                                                                              • 3




                                                                                $begingroup$
                                                                                You may want to wait a day or so before answering your own questions next time.
                                                                                $endgroup$
                                                                                – fəˈnɛtɪk
                                                                                Jan 11 at 20:11










                                                                              • $begingroup$
                                                                                71 bytes
                                                                                $endgroup$
                                                                                – Luis felipe De jesus Munoz
                                                                                Jan 11 at 20:16










                                                                              • $begingroup$
                                                                                Alternative 71 bytes
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 11 at 20:33






                                                                              • 1




                                                                                $begingroup$
                                                                                @LuisfelipeDejesusMunoz, that's different enough for you to post yourself.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 11 at 21:49










                                                                              • $begingroup$
                                                                                @LuisfelipeDejesusMunoz 66 bytes to tie you with Arnauld.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 12 at 13:50














                                                                              2












                                                                              2








                                                                              2





                                                                              $begingroup$

                                                                              Javascript ES6, 76 66 bytes



                                                                              x=>new Date(x).toJSON().slice(2,16).replace(/D/g,a=>a>'S'?'.':'')


                                                                              Try it online



                                                                              -10 bytes thanks to Shaggy!





                                                                              x // timestamp
                                                                              =>
                                                                              new Date(x) // date object from timestamp
                                                                              .toJSON() // same as .toISOString()
                                                                              .slice(2,16) // cut off excess
                                                                              .replace(/D/g, // match all non-digits
                                                                              a // a is matched character
                                                                              =>
                                                                              a>'S'?'.' // if a is T (bigger than S is shorter) replace it with .
                                                                              :'' // if it's not T, replace it with nothing
                                                                              // this way the dashes get removed and the dot gets put in the right place
                                                                              ) // end of replace





                                                                              share|improve this answer











                                                                              $endgroup$



                                                                              Javascript ES6, 76 66 bytes



                                                                              x=>new Date(x).toJSON().slice(2,16).replace(/D/g,a=>a>'S'?'.':'')


                                                                              Try it online



                                                                              -10 bytes thanks to Shaggy!





                                                                              x // timestamp
                                                                              =>
                                                                              new Date(x) // date object from timestamp
                                                                              .toJSON() // same as .toISOString()
                                                                              .slice(2,16) // cut off excess
                                                                              .replace(/D/g, // match all non-digits
                                                                              a // a is matched character
                                                                              =>
                                                                              a>'S'?'.' // if a is T (bigger than S is shorter) replace it with .
                                                                              :'' // if it's not T, replace it with nothing
                                                                              // this way the dashes get removed and the dot gets put in the right place
                                                                              ) // end of replace






                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited Jan 12 at 18:38

























                                                                              answered Jan 11 at 19:27









                                                                              skiilaaskiilaa

                                                                              1638




                                                                              1638








                                                                              • 3




                                                                                $begingroup$
                                                                                You may want to wait a day or so before answering your own questions next time.
                                                                                $endgroup$
                                                                                – fəˈnɛtɪk
                                                                                Jan 11 at 20:11










                                                                              • $begingroup$
                                                                                71 bytes
                                                                                $endgroup$
                                                                                – Luis felipe De jesus Munoz
                                                                                Jan 11 at 20:16










                                                                              • $begingroup$
                                                                                Alternative 71 bytes
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 11 at 20:33






                                                                              • 1




                                                                                $begingroup$
                                                                                @LuisfelipeDejesusMunoz, that's different enough for you to post yourself.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 11 at 21:49










                                                                              • $begingroup$
                                                                                @LuisfelipeDejesusMunoz 66 bytes to tie you with Arnauld.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 12 at 13:50














                                                                              • 3




                                                                                $begingroup$
                                                                                You may want to wait a day or so before answering your own questions next time.
                                                                                $endgroup$
                                                                                – fəˈnɛtɪk
                                                                                Jan 11 at 20:11










                                                                              • $begingroup$
                                                                                71 bytes
                                                                                $endgroup$
                                                                                – Luis felipe De jesus Munoz
                                                                                Jan 11 at 20:16










                                                                              • $begingroup$
                                                                                Alternative 71 bytes
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 11 at 20:33






                                                                              • 1




                                                                                $begingroup$
                                                                                @LuisfelipeDejesusMunoz, that's different enough for you to post yourself.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 11 at 21:49










                                                                              • $begingroup$
                                                                                @LuisfelipeDejesusMunoz 66 bytes to tie you with Arnauld.
                                                                                $endgroup$
                                                                                – Shaggy
                                                                                Jan 12 at 13:50








                                                                              3




                                                                              3




                                                                              $begingroup$
                                                                              You may want to wait a day or so before answering your own questions next time.
                                                                              $endgroup$
                                                                              – fəˈnɛtɪk
                                                                              Jan 11 at 20:11




                                                                              $begingroup$
                                                                              You may want to wait a day or so before answering your own questions next time.
                                                                              $endgroup$
                                                                              – fəˈnɛtɪk
                                                                              Jan 11 at 20:11












                                                                              $begingroup$
                                                                              71 bytes
                                                                              $endgroup$
                                                                              – Luis felipe De jesus Munoz
                                                                              Jan 11 at 20:16




                                                                              $begingroup$
                                                                              71 bytes
                                                                              $endgroup$
                                                                              – Luis felipe De jesus Munoz
                                                                              Jan 11 at 20:16












                                                                              $begingroup$
                                                                              Alternative 71 bytes
                                                                              $endgroup$
                                                                              – Shaggy
                                                                              Jan 11 at 20:33




                                                                              $begingroup$
                                                                              Alternative 71 bytes
                                                                              $endgroup$
                                                                              – Shaggy
                                                                              Jan 11 at 20:33




                                                                              1




                                                                              1




                                                                              $begingroup$
                                                                              @LuisfelipeDejesusMunoz, that's different enough for you to post yourself.
                                                                              $endgroup$
                                                                              – Shaggy
                                                                              Jan 11 at 21:49




                                                                              $begingroup$
                                                                              @LuisfelipeDejesusMunoz, that's different enough for you to post yourself.
                                                                              $endgroup$
                                                                              – Shaggy
                                                                              Jan 11 at 21:49












                                                                              $begingroup$
                                                                              @LuisfelipeDejesusMunoz 66 bytes to tie you with Arnauld.
                                                                              $endgroup$
                                                                              – Shaggy
                                                                              Jan 12 at 13:50




                                                                              $begingroup$
                                                                              @LuisfelipeDejesusMunoz 66 bytes to tie you with Arnauld.
                                                                              $endgroup$
                                                                              – Shaggy
                                                                              Jan 12 at 13:50











                                                                              2












                                                                              $begingroup$


                                                                              C (clang), 117 111 bytes



                                                                              Thanks to @chux and @ceilingcat for the suggestions.





                                                                              #import<time.h>
                                                                              *l;f(long t){t/=1e3;printf("%02d%02d%02d.%02d%02d",5[l=gmtime(&t)]%100,l[4]+1,l[3],l[2],l[1]);}


                                                                              Try it online!






                                                                              share|improve this answer











                                                                              $endgroup$













                                                                              • $begingroup$
                                                                                gmtime is short than localtime
                                                                                $endgroup$
                                                                                – chux
                                                                                Jan 13 at 22:08
















                                                                              2












                                                                              $begingroup$


                                                                              C (clang), 117 111 bytes



                                                                              Thanks to @chux and @ceilingcat for the suggestions.





                                                                              #import<time.h>
                                                                              *l;f(long t){t/=1e3;printf("%02d%02d%02d.%02d%02d",5[l=gmtime(&t)]%100,l[4]+1,l[3],l[2],l[1]);}


                                                                              Try it online!






                                                                              share|improve this answer











                                                                              $endgroup$













                                                                              • $begingroup$
                                                                                gmtime is short than localtime
                                                                                $endgroup$
                                                                                – chux
                                                                                Jan 13 at 22:08














                                                                              2












                                                                              2








                                                                              2





                                                                              $begingroup$


                                                                              C (clang), 117 111 bytes



                                                                              Thanks to @chux and @ceilingcat for the suggestions.





                                                                              #import<time.h>
                                                                              *l;f(long t){t/=1e3;printf("%02d%02d%02d.%02d%02d",5[l=gmtime(&t)]%100,l[4]+1,l[3],l[2],l[1]);}


                                                                              Try it online!






                                                                              share|improve this answer











                                                                              $endgroup$




                                                                              C (clang), 117 111 bytes



                                                                              Thanks to @chux and @ceilingcat for the suggestions.





                                                                              #import<time.h>
                                                                              *l;f(long t){t/=1e3;printf("%02d%02d%02d.%02d%02d",5[l=gmtime(&t)]%100,l[4]+1,l[3],l[2],l[1]);}


                                                                              Try it online!







                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited Jan 14 at 12:15

























                                                                              answered Jan 12 at 3:26









                                                                              ErikFErikF

                                                                              1,29917




                                                                              1,29917












                                                                              • $begingroup$
                                                                                gmtime is short than localtime
                                                                                $endgroup$
                                                                                – chux
                                                                                Jan 13 at 22:08


















                                                                              • $begingroup$
                                                                                gmtime is short than localtime
                                                                                $endgroup$
                                                                                – chux
                                                                                Jan 13 at 22:08
















                                                                              $begingroup$
                                                                              gmtime is short than localtime
                                                                              $endgroup$
                                                                              – chux
                                                                              Jan 13 at 22:08




                                                                              $begingroup$
                                                                              gmtime is short than localtime
                                                                              $endgroup$
                                                                              – chux
                                                                              Jan 13 at 22:08











                                                                              2












                                                                              $begingroup$

                                                                              Twig, 25 characters



                                                                              {{d[:-3]|date('ymd.hi')}}


                                                                              This is a template. Call it by including it and pass the Unix time as parameter d.



                                                                              Sample usage:



                                                                              {{include('datetime.twig', {'d': 1547233866744})}}


                                                                              Try it on TwigFiddle






                                                                              share|improve this answer









                                                                              $endgroup$


















                                                                                2












                                                                                $begingroup$

                                                                                Twig, 25 characters



                                                                                {{d[:-3]|date('ymd.hi')}}


                                                                                This is a template. Call it by including it and pass the Unix time as parameter d.



                                                                                Sample usage:



                                                                                {{include('datetime.twig', {'d': 1547233866744})}}


                                                                                Try it on TwigFiddle






                                                                                share|improve this answer









                                                                                $endgroup$
















                                                                                  2












                                                                                  2








                                                                                  2





                                                                                  $begingroup$

                                                                                  Twig, 25 characters



                                                                                  {{d[:-3]|date('ymd.hi')}}


                                                                                  This is a template. Call it by including it and pass the Unix time as parameter d.



                                                                                  Sample usage:



                                                                                  {{include('datetime.twig', {'d': 1547233866744})}}


                                                                                  Try it on TwigFiddle






                                                                                  share|improve this answer









                                                                                  $endgroup$



                                                                                  Twig, 25 characters



                                                                                  {{d[:-3]|date('ymd.hi')}}


                                                                                  This is a template. Call it by including it and pass the Unix time as parameter d.



                                                                                  Sample usage:



                                                                                  {{include('datetime.twig', {'d': 1547233866744})}}


                                                                                  Try it on TwigFiddle







                                                                                  share|improve this answer












                                                                                  share|improve this answer



                                                                                  share|improve this answer










                                                                                  answered Jan 14 at 13:13









                                                                                  manatworkmanatwork

                                                                                  16.3k43572




                                                                                  16.3k43572























                                                                                      2












                                                                                      $begingroup$

                                                                                      JavaScript, 64 bytes





                                                                                      n=>'2356891911121415'.replace(/1?./g,x=>new Date(n).toJSON()[x])


                                                                                      Try it online!






                                                                                      share|improve this answer









                                                                                      $endgroup$













                                                                                      • $begingroup$
                                                                                        aw, so close
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        Jan 15 at 5:47










                                                                                      • $begingroup$
                                                                                        also 64
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        Jan 15 at 5:48


















                                                                                      2












                                                                                      $begingroup$

                                                                                      JavaScript, 64 bytes





                                                                                      n=>'2356891911121415'.replace(/1?./g,x=>new Date(n).toJSON()[x])


                                                                                      Try it online!






                                                                                      share|improve this answer









                                                                                      $endgroup$













                                                                                      • $begingroup$
                                                                                        aw, so close
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        Jan 15 at 5:47










                                                                                      • $begingroup$
                                                                                        also 64
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        Jan 15 at 5:48
















                                                                                      2












                                                                                      2








                                                                                      2





                                                                                      $begingroup$

                                                                                      JavaScript, 64 bytes





                                                                                      n=>'2356891911121415'.replace(/1?./g,x=>new Date(n).toJSON()[x])


                                                                                      Try it online!






                                                                                      share|improve this answer









                                                                                      $endgroup$



                                                                                      JavaScript, 64 bytes





                                                                                      n=>'2356891911121415'.replace(/1?./g,x=>new Date(n).toJSON()[x])


                                                                                      Try it online!







                                                                                      share|improve this answer












                                                                                      share|improve this answer



                                                                                      share|improve this answer










                                                                                      answered Jan 15 at 2:36









                                                                                      tshtsh

                                                                                      8,61511547




                                                                                      8,61511547












                                                                                      • $begingroup$
                                                                                        aw, so close
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        Jan 15 at 5:47










                                                                                      • $begingroup$
                                                                                        also 64
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        Jan 15 at 5:48




















                                                                                      • $begingroup$
                                                                                        aw, so close
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        Jan 15 at 5:47










                                                                                      • $begingroup$
                                                                                        also 64
                                                                                        $endgroup$
                                                                                        – ASCII-only
                                                                                        Jan 15 at 5:48


















                                                                                      $begingroup$
                                                                                      aw, so close
                                                                                      $endgroup$
                                                                                      – ASCII-only
                                                                                      Jan 15 at 5:47




                                                                                      $begingroup$
                                                                                      aw, so close
                                                                                      $endgroup$
                                                                                      – ASCII-only
                                                                                      Jan 15 at 5:47












                                                                                      $begingroup$
                                                                                      also 64
                                                                                      $endgroup$
                                                                                      – ASCII-only
                                                                                      Jan 15 at 5:48






                                                                                      $begingroup$
                                                                                      also 64
                                                                                      $endgroup$
                                                                                      – ASCII-only
                                                                                      Jan 15 at 5:48













                                                                                      1












                                                                                      $begingroup$

                                                                                      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









                                                                                      $endgroup$









                                                                                      • 3




                                                                                        $begingroup$
                                                                                        You don't need to count command-line flags anymore.
                                                                                        $endgroup$
                                                                                        – AdmBorkBork
                                                                                        Jan 11 at 20:28










                                                                                      • $begingroup$
                                                                                        Oops. Good to know. Thank you @AdmBorkBork.
                                                                                        $endgroup$
                                                                                        – manatwork
                                                                                        Jan 11 at 20:36










                                                                                      • $begingroup$
                                                                                        1000 -> 1e3
                                                                                        $endgroup$
                                                                                        – Shaggy
                                                                                        Jan 14 at 20:16
















                                                                                      1












                                                                                      $begingroup$

                                                                                      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









                                                                                      $endgroup$









                                                                                      • 3




                                                                                        $begingroup$
                                                                                        You don't need to count command-line flags anymore.
                                                                                        $endgroup$
                                                                                        – AdmBorkBork
                                                                                        Jan 11 at 20:28










                                                                                      • $begingroup$
                                                                                        Oops. Good to know. Thank you @AdmBorkBork.
                                                                                        $endgroup$
                                                                                        – manatwork
                                                                                        Jan 11 at 20:36










                                                                                      • $begingroup$
                                                                                        1000 -> 1e3
                                                                                        $endgroup$
                                                                                        – Shaggy
                                                                                        Jan 14 at 20:16














                                                                                      1












                                                                                      1








                                                                                      1





                                                                                      $begingroup$

                                                                                      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









                                                                                      $endgroup$



                                                                                      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 Jan 11 at 20:20









                                                                                      manatworkmanatwork

                                                                                      16.3k43572




                                                                                      16.3k43572








                                                                                      • 3




                                                                                        $begingroup$
                                                                                        You don't need to count command-line flags anymore.
                                                                                        $endgroup$
                                                                                        – AdmBorkBork
                                                                                        Jan 11 at 20:28










                                                                                      • $begingroup$
                                                                                        Oops. Good to know. Thank you @AdmBorkBork.
                                                                                        $endgroup$
                                                                                        – manatwork
                                                                                        Jan 11 at 20:36










                                                                                      • $begingroup$
                                                                                        1000 -> 1e3
                                                                                        $endgroup$
                                                                                        – Shaggy
                                                                                        Jan 14 at 20:16














                                                                                      • 3




                                                                                        $begingroup$
                                                                                        You don't need to count command-line flags anymore.
                                                                                        $endgroup$
                                                                                        – AdmBorkBork
                                                                                        Jan 11 at 20:28










                                                                                      • $begingroup$
                                                                                        Oops. Good to know. Thank you @AdmBorkBork.
                                                                                        $endgroup$
                                                                                        – manatwork
                                                                                        Jan 11 at 20:36










                                                                                      • $begingroup$
                                                                                        1000 -> 1e3
                                                                                        $endgroup$
                                                                                        – Shaggy
                                                                                        Jan 14 at 20:16








                                                                                      3




                                                                                      3




                                                                                      $begingroup$
                                                                                      You don't need to count command-line flags anymore.
                                                                                      $endgroup$
                                                                                      – AdmBorkBork
                                                                                      Jan 11 at 20:28




                                                                                      $begingroup$
                                                                                      You don't need to count command-line flags anymore.
                                                                                      $endgroup$
                                                                                      – AdmBorkBork
                                                                                      Jan 11 at 20:28












                                                                                      $begingroup$
                                                                                      Oops. Good to know. Thank you @AdmBorkBork.
                                                                                      $endgroup$
                                                                                      – manatwork
                                                                                      Jan 11 at 20:36




                                                                                      $begingroup$
                                                                                      Oops. Good to know. Thank you @AdmBorkBork.
                                                                                      $endgroup$
                                                                                      – manatwork
                                                                                      Jan 11 at 20:36












                                                                                      $begingroup$
                                                                                      1000 -> 1e3
                                                                                      $endgroup$
                                                                                      – Shaggy
                                                                                      Jan 14 at 20:16




                                                                                      $begingroup$
                                                                                      1000 -> 1e3
                                                                                      $endgroup$
                                                                                      – Shaggy
                                                                                      Jan 14 at 20:16











                                                                                      1












                                                                                      $begingroup$


                                                                                      ksh, 36 bytes





                                                                                      printf "%(%y%m%d.%H%M)T" $(($1/1e3))


                                                                                      Try it online!



                                                                                      Thanks to Jo King for 15 bytes saved






                                                                                      share|improve this answer











                                                                                      $endgroup$













                                                                                      • $begingroup$
                                                                                        The same in Bash would be just 35 characters: Try it online!
                                                                                        $endgroup$
                                                                                        – manatwork
                                                                                        Jan 13 at 15:25
















                                                                                      1












                                                                                      $begingroup$


                                                                                      ksh, 36 bytes





                                                                                      printf "%(%y%m%d.%H%M)T" $(($1/1e3))


                                                                                      Try it online!



                                                                                      Thanks to Jo King for 15 bytes saved






                                                                                      share|improve this answer











                                                                                      $endgroup$













                                                                                      • $begingroup$
                                                                                        The same in Bash would be just 35 characters: Try it online!
                                                                                        $endgroup$
                                                                                        – manatwork
                                                                                        Jan 13 at 15:25














                                                                                      1












                                                                                      1








                                                                                      1





                                                                                      $begingroup$


                                                                                      ksh, 36 bytes





                                                                                      printf "%(%y%m%d.%H%M)T" $(($1/1e3))


                                                                                      Try it online!



                                                                                      Thanks to Jo King for 15 bytes saved






                                                                                      share|improve this answer











                                                                                      $endgroup$




                                                                                      ksh, 36 bytes





                                                                                      printf "%(%y%m%d.%H%M)T" $(($1/1e3))


                                                                                      Try it online!



                                                                                      Thanks to Jo King for 15 bytes saved







                                                                                      share|improve this answer














                                                                                      share|improve this answer



                                                                                      share|improve this answer








                                                                                      edited Jan 12 at 2:55

























                                                                                      answered Jan 12 at 1:56









                                                                                      Sergiy KolodyazhnyySergiy Kolodyazhnyy

                                                                                      331110




                                                                                      331110












                                                                                      • $begingroup$
                                                                                        The same in Bash would be just 35 characters: Try it online!
                                                                                        $endgroup$
                                                                                        – manatwork
                                                                                        Jan 13 at 15:25


















                                                                                      • $begingroup$
                                                                                        The same in Bash would be just 35 characters: Try it online!
                                                                                        $endgroup$
                                                                                        – manatwork
                                                                                        Jan 13 at 15:25
















                                                                                      $begingroup$
                                                                                      The same in Bash would be just 35 characters: Try it online!
                                                                                      $endgroup$
                                                                                      – manatwork
                                                                                      Jan 13 at 15:25




                                                                                      $begingroup$
                                                                                      The same in Bash would be just 35 characters: Try it online!
                                                                                      $endgroup$
                                                                                      – manatwork
                                                                                      Jan 13 at 15:25











                                                                                      1












                                                                                      $begingroup$

                                                                                      MediaWiki, 46 bytes



                                                                                      {{#time:ymd.Hi|@{{#expr:floor({{{1}}}/1e3)}}}}





                                                                                      share|improve this answer









                                                                                      $endgroup$


















                                                                                        1












                                                                                        $begingroup$

                                                                                        MediaWiki, 46 bytes



                                                                                        {{#time:ymd.Hi|@{{#expr:floor({{{1}}}/1e3)}}}}





                                                                                        share|improve this answer









                                                                                        $endgroup$
















                                                                                          1












                                                                                          1








                                                                                          1





                                                                                          $begingroup$

                                                                                          MediaWiki, 46 bytes



                                                                                          {{#time:ymd.Hi|@{{#expr:floor({{{1}}}/1e3)}}}}





                                                                                          share|improve this answer









                                                                                          $endgroup$



                                                                                          MediaWiki, 46 bytes



                                                                                          {{#time:ymd.Hi|@{{#expr:floor({{{1}}}/1e3)}}}}






                                                                                          share|improve this answer












                                                                                          share|improve this answer



                                                                                          share|improve this answer










                                                                                          answered Jan 13 at 11:19









                                                                                          tshtsh

                                                                                          8,61511547




                                                                                          8,61511547























                                                                                              1












                                                                                              $begingroup$

                                                                                              Java 8, 78 bytes





                                                                                              n->new java.text.SimpleDateFormat("yyMMdd.HHmm").format(new java.util.Date(n))


                                                                                              Try it online.



                                                                                              Explanation:



                                                                                              n->                       // Method with long parameter and String return-type
                                                                                              new java.text.SimpleDateFormat("yyMMdd.HHmm")
                                                                                              // Create the formatter
                                                                                              .format( // Format the date to a String in this format and return it:
                                                                                              new java.util.Date( // Create a new Date
                                                                                              n)) // With the input-long as timestamp





                                                                                              share|improve this answer









                                                                                              $endgroup$


















                                                                                                1












                                                                                                $begingroup$

                                                                                                Java 8, 78 bytes





                                                                                                n->new java.text.SimpleDateFormat("yyMMdd.HHmm").format(new java.util.Date(n))


                                                                                                Try it online.



                                                                                                Explanation:



                                                                                                n->                       // Method with long parameter and String return-type
                                                                                                new java.text.SimpleDateFormat("yyMMdd.HHmm")
                                                                                                // Create the formatter
                                                                                                .format( // Format the date to a String in this format and return it:
                                                                                                new java.util.Date( // Create a new Date
                                                                                                n)) // With the input-long as timestamp





                                                                                                share|improve this answer









                                                                                                $endgroup$
















                                                                                                  1












                                                                                                  1








                                                                                                  1





                                                                                                  $begingroup$

                                                                                                  Java 8, 78 bytes





                                                                                                  n->new java.text.SimpleDateFormat("yyMMdd.HHmm").format(new java.util.Date(n))


                                                                                                  Try it online.



                                                                                                  Explanation:



                                                                                                  n->                       // Method with long parameter and String return-type
                                                                                                  new java.text.SimpleDateFormat("yyMMdd.HHmm")
                                                                                                  // Create the formatter
                                                                                                  .format( // Format the date to a String in this format and return it:
                                                                                                  new java.util.Date( // Create a new Date
                                                                                                  n)) // With the input-long as timestamp





                                                                                                  share|improve this answer









                                                                                                  $endgroup$



                                                                                                  Java 8, 78 bytes





                                                                                                  n->new java.text.SimpleDateFormat("yyMMdd.HHmm").format(new java.util.Date(n))


                                                                                                  Try it online.



                                                                                                  Explanation:



                                                                                                  n->                       // Method with long parameter and String return-type
                                                                                                  new java.text.SimpleDateFormat("yyMMdd.HHmm")
                                                                                                  // Create the formatter
                                                                                                  .format( // Format the date to a String in this format and return it:
                                                                                                  new java.util.Date( // Create a new Date
                                                                                                  n)) // With the input-long as timestamp






                                                                                                  share|improve this answer












                                                                                                  share|improve this answer



                                                                                                  share|improve this answer










                                                                                                  answered Jan 15 at 8:24









                                                                                                  Kevin CruijssenKevin Cruijssen

                                                                                                  36.8k555193




                                                                                                  36.8k555193






























                                                                                                      draft saved

                                                                                                      draft discarded




















































                                                                                                      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

                                                                                                      Mario Kart Wii

                                                                                                      What does “Dominus providebit” mean?

                                                                                                      Antonio Litta Visconti Arese