- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 01:25 PM
Hello,
We have a Start Date/Time variable on a Catalog Item like this:
Below screenshot was from a email script. How to remove seconds from time?
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 05:40 PM - edited 09-14-2023 05:43 PM
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".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 09:09 PM
Hello @Bert_c1
It works perfectly. You are a wonderful helper and a great programmer.
Thank you a million.
Happy outcome: