如何为Heroku设置时区

时间:2017-06-23 07:01:42

标签: node.js heroku time timezone google-cloud-functions

我编写了一个在Heroku(Global)上运行的Node.js服务器。在我的localhost中一切正常,但由于Heroku的时区是UTC,我的功能现在运行不正确。有人可以帮我设置一个默认时区吗?

这是我的代码:

router.get('/year/:yyear/:mmonth/:ddate/:hhours/:mminute/:sseconds/:fireTitle/:fireBody', function(req, res) {

      var year1 = req.params.yyear;
      var month1 = (req.params.mmonth)-1;
      var date1 = req.params.ddate;
      var hours1 = req.params.hhours;
      var minute1 = (req.params.mminute);
      var seconds1 = req.params.sseconds;


      var datetime = new Date((new Date)*1 - 1000*3600*5.5 );


      var responseObject= "Your Function has been set for : "+year1+month1+date1+hours1+minute1+seconds1 +" date "+ datetime;

      var cron = require('node-schedule');
      var date = new Date(year1, month1, date1, hours1, minute1, seconds1);

      cron.scheduleJob(date, function(){

        var request = require("request");

      request("This Function will run" , function(error, response, body) {
        console.log(body);
      });
      });

      res.send(responseObject);

});


module.exports = router;

1 个答案:

答案 0 :(得分:4)

您可以在heroku

中为您的应用做类似的事情

df['last_revenues'] = df['last_revenues'].apply(lambda rstr: '{:5.4f}'.format(float(rstr.split(' ')[1].replace('.','').replace(',', '.'))) if rstr != 'nan' else 'nan')

http://blog.pardner.com/2012/08/setting-the-default-time-zone-for-a-heroku-app/