The CreatorCon Call for Content is officially open! Get started here.

Need help on remove Seconds from Date/time field.

Jessica28
Tera Guru

Hello,

We have a Start Date/Time variable on a Catalog Item like this:

Jessica28_1-1694636506890.png

 

Below screenshot was from a email script.  How to remove seconds from time?

 

Jessica28_0-1694636361058.png

 

Thank you

1 ACCEPTED SOLUTION

 

var strTime = "0:4:00:00 PM";
var spacePos = strTime.indexOf(" ");
var firstPart = strTime.substring(0, spacePos-3);
var lastPart = strTime.substring(spacePos);
gs.info('spacePos = ' + spacePos + ', firstPart = ' + firstPart + ', lastPart = ' + lastPart);
strTime = firstPart + lastPart;
gs.info('strTime = ' + strTime);

 

You can use logic in lines 2 -6 without the 'gs.info()' line. Parse on the space since hours and minutes can be single digits. the above results in " strTime = 0:4:00 PM".

View solution in original post

10 REPLIES 10

Hello @Bert_c1 

It works perfectly. You are a wonderful helper and a great programmer.

Thank you a million.

 

Happy outcome:

Jessica28_0-1694750930476.png