JS for current timestamp in W3C WSDL date format -YYYY-MM-DDThh:mm:ssTZD

Not applicable

Is there a way to get current timestamp in W3C WSDL date format -> YYYY-MM-DDThh:mm:ssTZD

in Apigee Edge using java script without any 3rd party package installation?

Eg:

2013-06-09T14:04:54-08:00

Any one got it worked?

-Vinay

0 2 1,522
2 REPLIES 2

Former Community Member
Not applicable

Hi @Kamal I believe this sample js policy should do the trick:

var formattedDate = new Date(context.getVariable("system.timestamp")).toISOString();
context.setVariable("formattedDate", formattedDate);

See sample response in the header that I am returning in the screen shot below

The "formattedDate" variable can be used wherever you need to reference the current date/time in your proxy.

Let me know if this gives you what you are looking for?

screen-shot-2016-04-01-at-43903-pm.png

@Prithpal Bhogill , Above output is slightly different from OP query. Final part is not TZD. See similar question asked here.