How to assign current date time in Apigee Assign Message policy ?

Not applicable
 
1 4 5,929
4 REPLIES 4

Not applicable

I would like to know if there is a variable or a way to assign current date time or I need to write a JS or an xslt to consider a current date time

Not applicable

Take look at system variables in

http://apigee.com/docs/api-services/reference/variables-reference

system.timestamp

system.time ...etc

Apigee offers timestamp and I am looking for datetimestamp.. let me know if there are any variables as such.. thanks in advance

Not applicable

Hi @ManojAnand.Illa

as @sriki77 mentioned, system.timestamp variable gives you the unique timestamp from epoch. You can use javascript to format it to the way you want, and then re-populate it to another local variable if you want to use it somewhere else.

Here is a sample javascript that can help you do that.

var timestamp = context.getVariable("system.timestamp");


var mydate = new Date(timestamp);
var formatted_date = mydate.toString('dddd MMM yyyy h:mm:ss');


context.setVariable("formatted_date", formatted_date);

After I execute this javascript in a policy, I see the following variable in my trace

formatted_date Thu May 28 2015 00:19:10 GMT-0000 (UTC)


system.timestamp 1432772350789

Let me know if this is what you are looking for.