javascript - Parse.com how to include moment-timezone.js -


i have script in cloud code in parse.com. , i'm trying use moment-timezone.js because need convert timezone of installation string (ie "europe/paris") time offset utc (gmt).

my code far imported question :

var moment = require('cloud/moment.js'); var tz = require('cloud/moment-timezone.js');  function totimezone(time, zone) {     var format = 'yyyy/mm/dd hh:mm:ss zz';     return moment(time, format).tz(zone).format(format); } 

i have copied latest moment.js , moment-timezone.js files website cloud directory.

here error log in cloud code :

failed with: typeerror: object invalid date has no method 'tz' @ totimezone (main.js:6:30) @ query.find.success (main.js:19:17) @ parse.js:2:10161 @ e (parse.js:2:8941) @ parse.js:2:8390 @ array.foreach (native) @ object.x.each.x.foreach [as _arrayeach] (parse.js:1:661) @ c.extend.resolve (parse.js:2:8341) @ e (parse.js:2:9076) @ parse.js:2:8390 

according parse's documentation https://www.parse.com/docs/js/guide#cloud-code-modules-moment

you can try this:

var moment = require('cloud/moment'); var tz = require('cloud/moment-timezone'); 

Comments