2

I have stucked with a problem.

my code in Controller is:

'Date-' + system.now() + ':' + 'Time out-' + responseTime;

and I am getting response : Date-2013-11-19 10:19:33:Time out-3600

responseTime = 3600 (which is in seconds)

Here I want to add Date with Time out so that the response should come in this format: Date-2013-11-19 10:29:33

Above we have added 3600 seconds to 2013-11-19 10:19:33 and we are getting 2013-11-19 10:29:33

Any help??

2 Answers 2

4

You can add seconds to a DateTime in the following way:

DateTime dt = System.now(); // DateTime.now();  will also work here too
DateTime adjustedDt = dt.addSeconds(responseTime);

Also, 3600 seconds is an hour: 10:19:33 plus 3600 seconds is 11:19:33 not 10:29:33 as you mention above.

0

use this

dateTime dt=System.now().addSeconds(60);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .