# CONVERT "MM/DD/YYYY HH:MM:SS am/pm" (i.e. "03/25/2024 10:44:24 PM") into "YYYY-MM-DD HH:MM:SS" (i.e. "2024-03-25 22:44:24") using ONLY "$regexp(x,e,r,c)"

**URL:** https://community.mp3tag.de/t/convert-mm-dd-yyyy-hhss-am-pm-i-e-03-25-2024-1024-pm-into-yyyy-mm-dd-hhss-i-e-2024-03-25-2224-using-only-regexp-x-e-r-c/64204
**Category:** General Discussion
**Created:** [March 26, 2024, 10:00pm UTC](https://community.mp3tag.de/t/convert-mm-dd-yyyy-hhss-am-pm-i-e-03-25-2024-1024-pm-into-yyyy-mm-dd-hhss-i-e-2024-03-25-2224-using-only-regexp-x-e-r-c/64204 "2024-03-26T22:00:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![wneclass2018](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/cdc98d/32.png) [@wneclass2018](https://community.mp3tag.de/u/wneclass2018)
#### Post date: [March 26, 2024, 10:00pm UTC](https://community.mp3tag.de/t/convert-mm-dd-yyyy-hhss-am-pm-i-e-03-25-2024-1024-pm-into-yyyy-mm-dd-hhss-i-e-2024-03-25-2224-using-only-regexp-x-e-r-c/64204/1 "2024-03-26T22:00:23Z")

</div>

My apologies. I thought I posted this, at least a variation of it, back in October 25th 2022. Nonetheless, this SIX "$regexp(x,e,r,c)" string will CONVERT " **MM/DD/YYYY HH:MM:SS am/pm**" into " **YYYY-MM-DD HH:MM:SS**" (24-hours). For example, " **03/25/2024 10:44:24 PM**" will be converted to " **2024-03-25 22:44:24**". Likewise, if your date string is "DD/MM/YYYY", you should change the "$3-$1-$2", in `$regexp(%_file_mod_datetime%,'^(?<![\d])(\d{1,2})\D{1,}(\d{1,2})\D{1,}(\d{4})(?![\d])(?=[^\n]*$)',$3-$1-$2,1)`, INTO "$3-$2-$1".

**FULL STRING:**

> `$regexp($regexp($regexp($regexp($regexp($regexp(%_file_mod_datetime%,'^(?<![\d])(\d{1,2})\D{1,}(\d{1,2})\D{1,}(\d{4})(?![\d])(?=[^\n]*$)',$3-$1-$2,1),'(?<![\d])(0?[1-9]|1[0-1])(?![\d])(?=(?:[:]\d{1,2}){2}[\W_]*PM)',$add($regexp(%_file_mod_datetime%,'^.*(?<![\d])(0?[1-9]|1[0-1]):(\d{1,2}:\d{1,2})(?![\d]).*$',$1),12),1),'(?<![\d])(?:12)(?=(?:[:]\d{1,2}){2}[\W_]{0,}AM)',00,1),'[[:alpha:]_, \t]+',' ',1),'\s+$|^\s+',,1),'(?<![\d])(\d)(?![\d])',0$1)`

LASTLY, below, this is the string that I use for Columns sorting ( **see attached image of results** ):

`$regexp(%_file_mod_datetime%,'(?<![\d])(\d)(?![\d])',0$1) ⟷ $regexp($regexp($regexp($regexp($regexp($regexp(%_file_mod_datetime%,'^(?<![\d])(\d{1,2})\D{1,}(\d{1,2})\D{1,}(\d{4})(?![\d])(?=[^\n]*$)',$3-$1-$2,1),'(?<![\d])(0?[1-9]|1[0-1])(?![\d])(?=(?:[:]\d{1,2}){2}[\W_]*PM)',$add($regexp(%_file_mod_datetime%,'^.*(?<![\d])(0?[1-9]|1[0-1]):(\d{1,2}:\d{1,2})(?![\d]).*$',$1),12),1),'(?<![\d])(?:12)(?=(?:[:]\d{1,2}){2}[\W_]{0,}AM)',00,1),'[[:alpha:]_, \t]+',' ',1),'\s+$|^\s+',,1),'(?<![\d])(\d)(?![\d])',0$1)`

 ![Mp3tag v3.24 (64-bit) (Windows OS) (01-26-2024)_ SYSTEM's Last Date MODIFIED (AM⧸PM) AND 24-hrs (10-25-2022) Win OS System_ Image 4K (2024-03-26)_(13 hr_02 min_36 secs)](https://community.mp3tag.de/uploads/default/original/3X/3/7/37053ac0de6cdfb7e73b75d8fe776cb01f3a142a.png)

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [March 27, 2024, 7:35am UTC](https://community.mp3tag.de/t/convert-mm-dd-yyyy-hhss-am-pm-i-e-03-25-2024-1024-pm-into-yyyy-mm-dd-hhss-i-e-2024-03-25-2224-using-only-regexp-x-e-r-c/64204/2 "2024-03-27T07:35:17Z")

</div>

> [@wneclass2018](#):
>
> LASTLY, below, this is the string that I use for Columns sorting

If you use the "raw" values of the date in the property "Sort by" for a column, you could save a lot of typing:  
See

> **[Format Strings and Placeholders – Mp3tag Documentation](https://docs.mp3tag.de/format/#file-properties)**
>
> Documentation on format strings and placeholders to describe the structure of file names and imported data. Mp3tag is the universal Tag Editor.

`%_file_create_datetime_raw%`: Long creation date (unformatted)  
`%_file_mod_datetime_raw%`: Long modification date (unformatted)

---

<div class="post-metadata">

### Author: ![wneclass2018](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/cdc98d/32.png) [@wneclass2018](https://community.mp3tag.de/u/wneclass2018)
#### Post date: [March 27, 2024, 8:21am UTC](https://community.mp3tag.de/t/convert-mm-dd-yyyy-hhss-am-pm-i-e-03-25-2024-1024-pm-into-yyyy-mm-dd-hhss-i-e-2024-03-25-2224-using-only-regexp-x-e-r-c/64204/3 "2024-03-27T08:21:07Z")

</div>

There seems to be some miscommunication on my part, and I addressed it by switching the category from "Support" to "General Discussion". My post was to provide a string for anyone looking to convert date and time (i.e. "MM/DD/YYYY HH:MM:SS") to YYYY-MM-DD HH:MM:SS. I am very much aware of `%_file_create_datetime_raw%` and `%_file_mod_datetime_raw%` as sorting options, and I can also use the EPOCH string that I created as well.
