通过服务提供商更改应用时区

时间:2017-11-27 02:44:33

标签: php laravel timezone

我正在尝试制作一个可以通过.env文件更改应用时区的包。

在我的.env文件中,我添加了以下行:

APP_TIMEZONE=America/Toronto

现在,在我的包服务提供者类中,我在boot()方法中有以下内容:

\Log::info(config('app.timezone'));
config(['app.timezone' => env('APP_TIMEZONE', 'UTC)')]);
\Log::info(config('app.timezone'));

我的日志文件确认app.timezone已从UTC更改为America/Toronto。但是,当我将新记录插入数据库时​​,created_at列仍然使用UTC

为什么会这样?在Laravel工作当地时区正在成为一场噩梦。

1 个答案:

答案 0 :(得分:0)

您似乎忘了运行import matplotlib.pyplot as plt import numpy as np import matplotlib.animation as animation from mpl_toolkits.mplot3d import Axes3D import matplotlib.patches as mpatches total = 10 num_whatever = 100 # old = 5120 to_plot = [np.random.rand(num_whatever, 3) for i in range(total)] colors = [['r' if i%2==0 else 'b' for i in range(num_whatever)] for i in range(total)] red_patch = mpatches.Patch(color='red', label='Men') blue_patch = mpatches.Patch(color='blue', label='Women') fig = plt.figure() ax3d = Axes3D(fig) scat3D = ax3d.scatter([],[],[], s=10) ttl = ax3d.text2D(0.05, 0.95, "", transform=ax3d.transAxes) def update_plot(i): print i, to_plot[i].shape ttl.set_text('PCA on 3 components at step = {}'.format(i*20)) scat3D._offsets3d = np.transpose(to_plot[i]) scat3D.set_color(colors[i]) return scat3D, def init(): scat3D.set_offsets([[],[],[]]) ax3d.set_xlim(-1.,2.) ax3d.set_ylim(-0.5,0.7) ax3d.set_zlim(-1.,0.75) plt.style.use('ggplot') plt.legend(handles=[red_patch, blue_patch]) ani = animation.FuncAnimation(fig, update_plot, init_func=init, blit=False, interval=100, frames=xrange(total)) # ani.save(os.path.join(config.workdir, 'gif', 'bins','anim.gif'), writer="imagemagick") plt.plot()

相关问题