Ask Your Question

How to add or subtract time from date/time field

asked 2018-07-21 20:52:35 -0500

rleyba gravatar image

updated 2018-07-23 15:14:15 -0500

metadaddy gravatar image

Hi Team,

I have a requirement where I would want to add some hours or minutes to my time variable.

For example: How would I do this?

${time:now()} - 4 hours.

I want to do add/subtract from current time like how they do it in bash -->

Thanks and regards.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-07-23 15:16:04 -0500

metadaddy gravatar image

You can do this by converting the DateTime to a long, performing the arithmetic, then converting it back:

${time:millisecondsToDateTime(time:dateTimeToMilliseconds(time:now()) - (4 * 3600 * 1000))}

If you have ideas on how this could be done more elegantly, then please feel free to submit an enhancement request at

edit flag offensive delete link more


Yes, understood. This solution will work for me. Thanks very much.

rleyba gravatar imagerleyba ( 2018-07-24 05:59:27 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-07-21 20:52:35 -0500

Seen: 41 times

Last updated: Jul 23