I have strings like:
-4:00
3:15
+8:30
I need to format them as UTC offset values like:
-0400
+0315
+0815
How can I convert the sample strings to the final strings? I know it probably uses some combo of str_replace and sprintf, but I cannot work it out.
Thanks!
In three steps here it is:
You can remove the
mflag on the second regex if you are only passing one offset at a time.