Reputation: 233
I must use time offset value to change the time. I make it via
// serwer time is XYZ Time Zone date time
$date_today_tz = date("Y-m-d H:i"); // actual date time from XYZ time zone
$time_diff_UTC = date('P'); // diff to UTC
$_time = explode(":",$time_diff_UTC);
$time_diff_UTC_strt = $_time[0]." hours ".$_time[1]." minutes";
and
gmdate('Y-m-d H:i:s', strtotime($time_diff_UTC_strt, strtotime($date_today_tz)));
I have a time from a XYZ time zone and a time offset (to this time) from UTC (f.ex. -07:00)
$time_diff_UTC = date('P');
But (for another part of my code) I must have the value of this offset but with opposite sign f.ex.
-07:00 -> +07:00
+01:00 -> -01:00
ect.
As the easiest way to do it?
Upvotes: 0
Views: 334
Reputation: 65264
Have you tried
str_replace(array('-','+','#'), array('#','-','+'), $time_diff_UTC)
Upvotes: 3