convert current time to format along with timezone

Not applicable

how can i convert the system time to format as follows

YYYYMMDDhh:mm:ss-zz:zz

If its eastern the format is 2015091015:10:15-04:00.

Tried to use the following from another question

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

var mydate = new Date(timestamp); 

var formatted_date = mydate.toString('yyyyMMddhh:mm:ss');

But it keeps on printing in the following format

formatted_date ThuMay28201500:19:10 GMT-0000(UTC)

Solved Solved
1 4 3,338
1 ACCEPTED SOLUTION

I don think toString() supports arguments, I have used http://momentjs.com/ in the past, you can include them in your JS policy for date manipulation and formatting

View solution in original post

4 REPLIES 4

I don think toString() supports arguments, I have used http://momentjs.com/ in the past, you can include them in your JS policy for date manipulation and formatting

Thanks worked perfectly fine.

moment().utcOffset('-04:00').format('YYYYMMDDHH:mm:ssZ')

@Mukundha Madhavan @satishbabu.kodali Could you please let me know how to include this in my javascript as I am getting Javascript runtime error: \"ReferenceError: \"moment\" is not defined.

@Madhuri Sridharan , See Q & A here.