AWS LambdaでDateを使う時の注意点

NGのケース

process.env.TZ = "Asia/Tokyo";
var aws = require('aws-sdk');
var async = require('async');
aws.config.update({
    region: 'ap-northeast-1'
});
var today = new Date();


exports.handler = function (event, context) {
    console.log(today);
};

OKのケース

process.env.TZ = "Asia/Tokyo";
var aws = require('aws-sdk');
var async = require('async');
aws.config.update({
    region: 'ap-northeast-1'
});

exports.handler = function (event, context) {
    var today = new Date();
    console.log(today);
};

exports.handlerの中で new Date();しないと、1回目のLambda実行時の時刻で固定になっていまいます。