Forum Discussion

Norman Young's avatar
Apr 01, 2019

Remove seconds from JSON view format

Hello All,

 

I am customizing the Bulletin Board JSON view format and can't figure out how to remove the seconds from the time entry. See image below.

Here is the code that I believe needs to be updated:

 

"txtContent": "=toLocaleTimeString([$StartTime]) + ' - ' + toLocaleTimeString([$EndTime])"

 

Any ideas?

 

Thanks.

 

Norm

1 Reply

  • Hubert_Lam's avatar
    Hubert_Lam
    Copper Contributor

      

    After a bit of fiddling and reading up on the indexOf/substring functions:

     

    txtContent": "=substring(@currentField.displayValue, indexOf(@currentField.displayValue,' '), indexOf(@currentField.displayValue + '*','*'))"

     

     

    Explanation:

    • The substring will try to remove the date (e.g. 5/4/2023) 
      • The first indexOf will try to find the first space in the date field
      • The second indexOf will try to find the position of the last character in the string

    The 5:36 pm that appears in the following formatted column arises from the use of the substring/indexOf:

     

     

    Norman Young

Resources