New to Notepad++ and trying to convert 12 hour time to 24
-
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!
-
@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:mmas 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-modeFor 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
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