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??


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.


use this

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.