Date time again ...



  • 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?



  • @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"))


  • @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



  • @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!



  • @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



  • @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.


Log in to reply