Take someone from Europe/Paris (+02:00) for example.
I want to build a function where I pass in a date and time string ('2016-10-6 06:00 PM') and my time zone identifier ('Europe/Paris'). I want to return the corresponding GMT timestamp.
getTimestamp('2016-10-6 06:00 PM', 'Europe/Paris')
Here is what I have so far:
public function getTimestamp($string, $time_zone)
{
$c = Carbon::parse($string);
$c->timezone = new DateTimeZone($time_zone);
return $c->timestamp;
}
Problem
If a pass a date and time of 2016-10-06 06:00 PM
and a time zone of Europe/Paris
I get back a UTC timestamp that corresponds to 2016-10-06 06:00 PM GMT.
It should be returning a time of 04:00 GMT because Europe/Paris is two hours ahead.
Question
How do I pass a date and time zone and get back a GMT timestamp with the correct offset.