You can do so using #PowerQuery
(available in Excel 2010 and later versions) apart from formula based solution.
The logic is to add the data to the power query editor, use the Replace Values function under the Transform
tab to replace 08:00 a. m.
with 1
and replace 08:00 p. m.
with 0
, and then use Merge Columns function under the Transform
tab to merge all columns with comma ,
as the delimiter. The outcome may look like the following. You can load the result to a new worksheet (by default) or create a connection to this query and load it to a specific location but the limitation is that it has to be in a Table.

Here is the full power query m code behind the scene for reference only. All functions are performed using built-in functions.
let
Source = Excel.CurrentWorkbook(){[Name="YourTable"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type any}, {"Column2", type any}, {"Column3", type any}, {"Column4", type any}, {"Column5", type text}, {"Column6", type text}, {"Column7", type text}, {"Column8", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","08:00 a. m.",1,Replacer.ReplaceValue,{"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","08:00 p. m.",0,Replacer.ReplaceValue,{"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8"}),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Replaced Value1", {{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}, {"Column7", type text}, {"Column8", type text}}, "en-AU"),{"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8"},Combiner.CombineTextByDelimiter(",", QuoteStyle.None),"Merged")
in
#"Merged Columns"