Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › datetime regexpression help
Hi all,
So I need to turn a datetime that looks like 22060831120000 into this:
8/31/2006, 1200 Hours (i don’t need to keep seconds).
Any regexpression experts out there that can save me from about 10 lines of code using string range and append?
Thanks in advance,
I assume the string is really 20060831120000. When dealing with dates I would recommend you always use the clock command.
First you need your date in a format you can scan which means a space between date and time
set dt 20060831120000
regsub — {(d{8})(d+)} $dt {1 2} dt
echo [clock format [clock scan $dt -format “%m/%d/%Y, %H%M Hours”]
==> 08/31/2006, 1200 Hours
Adjust the format as needed
If you want to just use a regsub:
regsub {(d{4})(d{2})(d{2})(d{4})d{2}} $date {2/3/1, 4 Hours} date