I have a date stored in a database with timezone UTC, the date is a few days/hours/minutes ahead of right now.
I then need to calculate the difference in time between right now and the given date, bearing in mind that there could be different timezones at play.
I have been doing the following but it is wrong as the timezone isn’t taken into consideration.
$interval = date_create('now')->diff(date_create($listing_end_date));
//$interval->d = days
//$interval->h = hours
//$interval->i = minutes
How can I do the above with the timezone taken into account?
You need to pass a second argument to
date_createtelling it what time zone is represented by the date in$listing_end_date. For example, assuming the string is in UTC: