4

I'm using moment-timezone@0.5.23.

const moment = require('moment-timezone');
...
const now = moment().tz('America/Los_Angeles');
console.log(now.format('dddd');

This works well when I run it on my laptop. However, when I deploy the code to my AWS Lambda function running on Node 8.10, I see this in the log

Moment Timezone has no data for "America/Los_Angeles". See 
http://momentjs.com/timezone/docs/#/data-loading/.

As the result, I end up with the time of either America/New_York or UTC instead of America/Los_Angeles.

I've tried to copied the packed data over and loaded it manually (moment.tz.load(require('./latest'));) but still got the same error.

Any way to make moment-timezone work properly on AWS Lambda?

Thanks,

chepukha
  • 2,371
  • 3
  • 28
  • 40
  • 1
    I figured out the problem. In my actually code, I passed in the timezone code from another function which includes extra quotes in it. There's no problem with moment-timezone here. I'm going to close this question to avoid confusion. – chepukha Dec 03 '18 at 23:52

0 Answers0