cloud, javascript

Using MomentJs Timezone in Parse.Cloud.code

Parse Cloud Code comes with a few handy modules, however momentjs presently is very old (1.x) on parse cloud code. Here are the steps how to integrate momentjs and momentjs-timezone (latest and greatest).

Step 1

Within your project copy momentjs.js (version 2.X) and moment-timezone.js file to /cloud directory.

Step 2

Modify moment-timezone.js first few lines:

(function (root, factory) {
"use strict";

module.exports = factory(require(‘cloud/moment.js’));

}(this, function (moment) {

What this does is loads your updated momentJs for moment-timezone to use

Step 3

Use the updated script within your code like this

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

Share This: