Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

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,661
1 ACCEPTED SOLUTION

gnanasekaran
Former Googler

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