Reputation: 10044
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?
Upvotes: 0
Views: 558
Reputation: 10044
Ended up using the moment-timezone-with-data
plugin and auto-populating a hidden timezone
field with moment.tz.guess()
.
Upvotes: 1