Community
    • Login

    New to Notepad++ and trying to convert 12 hour time to 24

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 20 Views 1 Watching
    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.
    • Matt LongM Offline
      Matt Long
      last edited by

      Good Afternoon

      I am new to Notepad++ and I am trying to write a script to convert 12 hour time into 24 hour time format. Below is the data string that I have to convert:

      01-May-26 12:15:00 AM,689.1,WESTHAMPTON_HALL_Elec

      This is just one string out of 600+ but I ultimately need them all to read like:

      5/1/2026 00:15,689.1,WESTHAMPTON_HALL_Elec

      Any assistance is much appreciated!

      CoisesC 1 Reply Last reply Reply Quote 0
      • CoisesC Online
        Coises @Matt Long
        last edited by Coises

        @Matt-Long said:
        I am new to Notepad++ and I am trying to write a script to convert 12 hour time into 24 hour time format. Below is the data string that I have to convert:

        01-May-26 12:15:00 AM,689.1,WESTHAMPTON_HALL_Elec

        This is just one string out of 600+ but I ultimately need them all to read like:

        5/1/2026 00:15,689.1,WESTHAMPTON_HALL_Elec

        The Timestamps… command in the Columns++ plugin can help with this.

        For conversion you want, you would select day-month-year in the From date and time section, then select Custom in the To date and time section, enter M/d/yyyy HH:mm as the custom picture, check Overwrite selection, then click To Date/Time to perform the conversion.

        To use this, you need to have all the timestamps lined up in a column and make a column selection. If your document has a series of lines like the example you gave with all three-character months, you can select it as is.

        If you have months spelled out, so that the right edge of the column doesn’t line up, you can use a regular expression to change the first comma to a tab, enable Elastic tabstops on the Columns++ menu, and then you can select the column, perform the conversion, and use another regular expression to convert the tabs back to commas. (Alternatively, if this is a CSV file, you can use the Conversion functions in Columns++ to convert from comma separated values to tabs and back again instead of using regular expressions.)

        If the timestamps don’t occur in contiguous column at all, we might have to devise a more inventive method of getting them into a column selection if you want to use Columns++ to do the conversion.

        For an explanation of how to make a column selection, see:
        https://npp-user-manual.org/docs/editing/#entering-column-mode

        For an explanation of how to install a plugin from the plugins list (Columns++ is in the list), see:
        https://npp-user-manual.org/docs/plugins/#install-using-plugins-admin

        1 Reply Last reply Reply Quote 1

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors