简体   繁体   中英

Bootstrap datetimepicker and Laravel timezones

My Laravel app is currently set to use UTC as a timezone. It uses this for all of the dates such as created_at and updated_at .

However, in my app I have a form which allows a user to specify a scheduled_at date using the Bootstrap datetimepicker plugin. Now the problem here is that the datetimepicker plugin uses momentjs in order to automatically display the date of the input in the users local timezone.

So I am trying to come up with a solution that will insert the date they enter as UTC. The biggest hurdle is that I want it to still display the input date in their current timezone, and then convert it before database insertion.

I was thinking I could have a hidden input field which would use momentjs to automatically populate it with their timezone name, and then use that hidden field to convert the date to UTC via Carbon.

Is this the best or only option I have?

最后使用moment-timezone-with-datamoment-timezone-with-data插件并使用moment.tz.guess()自动填充一个隐藏的timezone字段。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM