Community
    • Login

    Date time again ...

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 4 Posters 7.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Frank SønslienF
      Frank Sønslien
      last edited by

      I am using Notepad++ to log different stuff.
      In this process I am using a keyboard sequence to insert time and date, but later on on when browsing through the file I would really love to get the date first.

      So far I have not been able to swap time and date.

      I would like it this way:

      11.05.2017 07:50

      Not like this:
      07:50 11.05.2017

      Any one?

      Scott SumnerS Larsen E WhipsnadeL 2 Replies Last reply Reply Quote 0
      • Scott SumnerS
        Scott Sumner @Frank Sønslien
        last edited by

        @Frank-Sønslien

        Are you using the TextFX (plugin) to insert the date/time that way? The TextFX (menu) -> TextFX Insert -> Date & Time - short format looks a lot like your example text, but also adds AM or PM between the time and date.

        So if you’re willing to resort to programming, you can have whatever you want. For example, a little bit of Pythonscript yields your desired format, and could be tweaked even further to obtain virtually anything you can think of:

        import datetime
        # see https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior for format codes
        editor.addText(datetime.datetime.now().strftime("%m.%d.%Y %H.%M"))
        
        glennfromiowaG 1 Reply Last reply Reply Quote 2
        • glennfromiowaG
          glennfromiowa @Scott Sumner
          last edited by

          @Scott-Sumner, I think the code would actually be in this format (Day.Month.Year):

          editor.addText(datetime.datetime.now().strftime("%d.%m.%Y %H.%M"))
          

          @Frank-Sønslien, if you’re willing to do a regular expression, this should do it:
          Find What: (\d\d:\d\d) (\d\d\.\d\d\.\d\d\d\d)
          Replace with: \2 \1
          Regular expression: selected
          Click on Replace All

          Scott SumnerS 1 Reply Last reply Reply Quote 2
          • Scott SumnerS
            Scott Sumner @glennfromiowa
            last edited by Scott Sumner

            @glennfromiowa

            You are back again! Nice. Stop going away. :-D

            You are right about the date ordering, according to what the OP wanted. However, whenever I see 11.05 I think of November 5 and not May 11, as Nov. 5 is my anniversary!

            1 Reply Last reply Reply Quote 1
            • Larsen E WhipsnadeL
              Larsen E Whipsnade @Frank Sønslien
              last edited by Larsen E Whipsnade

              @Frank-Sønslien My NPP seems to read the date in ISO format from my Windows system date; I’d prefer to pick off the correct Windows date+time rather than patch the erroneous NPP display with Pythonscript or other patch tool

              Scott SumnerS 1 Reply Last reply Reply Quote 0
              • Scott SumnerS
                Scott Sumner @Larsen E Whipsnade
                last edited by

                @Larsen-E-Whipsnade

                Notepad++ doesn’t do anything at all involving the date, so there is no “erroneous NPP display”. If you are talking about the date string that comes from the TextFX plugin, that’s fine but that isn’t a complaint against Notepad++. Actually, I can’t really tell what your complaint is as you don’t provide much in the way of detail.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors