簡體   English   中英

獲取下一個星期六(UTC)PHP

[英]Get next saturday (UTC) PHP

我的目標:獲取下一個星期日的格林尼治標准時間+ 0 / UTC時間17:00:00的日期時間(倒計時)

User from +0 GMT gets: 2014/01/11 17:00:00
User from +1 GMT gets: 2014/01/11 18:00:00
User from +3 GMT gets: 2014/01/11 20:00:00
etc.

我已經走了這么遠:

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

現在的問題是:它是在本地時間(而不是GMT + 0星期六時間)累計17小時。

我還嘗試了許多其他操作,但似乎沒有任何效果。

它不起作用,因為您必須將時區設置為地方

喜歡:

  date_default_timezone_set('America/Los_Angeles');

以下是所有時區的列表:

http://php.net/manual/en/timezones.php

更新:

嘗試這個:

$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 . ";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM