Laravel 5.3:根据用户位置设置时区 [英] Laravel 5.3 : Setting time zones based on users location

查看:192
本文介绍了Laravel 5.3:根据用户位置设置时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Laravel 5.3中有一个小型博客应用程序,其中我需要一些有关在以下功能上设置时间戳的建议

We have small blog application in Laravel 5.3 in which i need some suggestion about setting time stamps on the following features

1.Admin可以将通知发送给具有当前时间戳记的所有用户 (服务器时区为Asia/Calcutta)用户将根据其时区查看所有通知.

1.Admin can able to send notifications to all users with current time stamp (server timezone is Asia/Calcutta) user will see all the notifications based on their time zones.

2.用户可以在其他用户根据自己的时区看到帖子时,将其与当前时间戳一起添加.

2.Users can add posts along with their current time stamps , when other users see that posts based on their time zones.

那么我需要对应用程序中的时区设置进行哪些更改?

So what are the changes i need to do on the timezone settings in my application??

推荐答案

您可能已经找到7个月大的问题的答案.无论如何,我只是在这里发布我为摆脱不同时区问题所做的工作.

You might have already found an answer to your 7 months old question. Anyway, I am just posting here what I did to get rid of different time zone issue.

首先阅读 Timo Huovinen 答案.

在我的应用程序中,用户应手动设置时区.基于此,在将MySQL时间发送到客户端之前,将其转换为适当的时区.

In my application, user should manually set the timezone. Based on it, convert MySQL time to appropriate timezone before sending it to client.

您可以使用convert_tz()函数在时区之间进行转换.

You can use convert_tz() function to convert between timezones.

这篇关于Laravel 5.3:根据用户位置设置时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆