Hey!
I'm working on converting today's date at midnight (00:00:00) into a UTC timestamp, based on the user's timezone. Here's the approach I'm using:
I format the
now
variable asY-m-d
to get today's date.I concatenate this date with
00:00:00
to represent the start of the day.Then, I use the "to_timestamp" function to convert the concatenation into a timestamp, specifying the user's timezone.
This gives me the correct UTC timestamp for when that specific day started in the user's timezone.
Is this a common or recommended approach?
How would others handle this scenario?
I want to make sure Im not over complicating things here
Thanks!