4m4d3u5
7 years agoContributor
Splitting strings
I have a string that is a time and a period that I want to parse; however, I want to parse this if the period is AM or PM. So the string for example with be: 8:40AM and I want to split that up into it's parts. What I want to do is split on the first letter so that it doesn't matter if it's am or pm so something like:
var timePeriod = 8:40AM
var timePeriodParsed= timePeriod .split(Is letter)
var period = timePeriodParsed[1]
var hourMinutes = timePeriodParsed[0]
print(period)
output: AM
print(hoursMinutes)
output: 8:40
I am pretty sure I have to format it then I can do what I want. I have to do aqConvert.DateTimeToFormatStr(timePeriod, "%c"), then I can get the string 8:40 AM, then I can split by space, then split by :