comparison between different times
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 05:42 AM
Hey
How do I reverse the string - '18:00:00'
for the time 18:00:00
for comparison between different times.
Thanks. Shir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 06:42 AM - edited 06-18-2024 06:44 AM
Hi @Shir Sharvit ,
Please try below script
var hms = "18:00:00";
var target = new Date("1970-01-01T" + hms);
gs.log(target);
Or
var now = new Date();
var nowDateTime = now.toISOString();
var nowDate = nowDateTime.split('T')[0];
var hms = '18:00:00';
var target = new Date(nowDate + 'T' + hms);
gs.log(target);
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 07:06 AM
sorry it doesn't work for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 07:19 AM
Hi @Shir Sharvit ,
Before doing the addition can you convert the dates using getNumericValue() functions it converts the date to milliseconds and then you can simply do the comparison and once you have the value of the date based on your logic you can set it back using setNumericValue().
Please mark helpful/correct if my response helped you.