获取下周六(UTC)PHP

获取下周六(UTC)PHP,php,timestamp,utc,Php,Timestamp,Utc,我的目标:获取下个星期天的日期时间:格林威治标准时间17:00:00+0/UTC时间(用于倒计时) 我走了这么远: date_default_timezone_set("UTC"); $nextsat = strtotime("next Saturday"); $saturday = date(strtotime('+17 hours', $nextsat)); 现在的问题是:在我的当地时间,它的计数是17个小时,而不是格林尼治标准时间+0周六时间 我还尝试了许多其他的方法,但似乎都不管用。它

我的目标:获取下个星期天的日期时间:格林威治标准时间17:00:00+0/UTC时间(用于倒计时)

我走了这么远:

date_default_timezone_set("UTC");
$nextsat = strtotime("next Saturday");
$saturday = date(strtotime('+17 hours', $nextsat));
现在的问题是:在我的当地时间,它的计数是17个小时,而不是格林尼治标准时间+0周六时间


我还尝试了许多其他的方法,但似乎都不管用。

它不管用,因为你必须将时区设置为地点

比如:

以下是所有时区的列表:

更新:

试试这个:

$nextsat = strtotime("next Saturday");
date_default_timezone_set("UTC");
$saturday = date(strtotime('+17 hours', $nextsat));

在“下周六”之后设置utc时间

您应该尝试以下观点,看看它是否能解决您的问题:

$h = "17";// Hour for time zone goes here e.g. +7 or -4, just remove the + or -
$hm = $h * 60; 
$ms = $hm * 60;
$gmdate = gmdate("m/d/Y g:i:s A", time()-($ms)); // the "-" can be switched to a plus if that's what your time zone is.
echo "Your current time now is :  $gmdate . ";

“UTC”工作正常,但我将其设置为欧洲/伦敦以防万一。问题是它仍然使用我的时间,而不是GMT+0/UTC 1。我在我的计算机上使用+1 GMT,它仍然显示17:00:00,而不是18:00:00,它应该显示给我。有什么想法吗?
$nextsat = strtotime("next Saturday");
date_default_timezone_set("UTC");
$saturday = date(strtotime('+17 hours', $nextsat));
$h = "17";// Hour for time zone goes here e.g. +7 or -4, just remove the + or -
$hm = $h * 60; 
$ms = $hm * 60;
$gmdate = gmdate("m/d/Y g:i:s A", time()-($ms)); // the "-" can be switched to a plus if that's what your time zone is.
echo "Your current time now is :  $gmdate . ";