CEST中的时间= UTC时间+ 2h 但我的代码只显示了1小时,我不知道为什么......(你可以测试它here)
require 'Carbon/Carbon.php';
use Carbon\Carbon;
$timestamp = '2018-04-06 14:30:00';
$date = Carbon::createFromFormat('Y-m-d H:i:s', $timestamp, 'UTC');
var_dump($date);
//{ ["date"]=> string(26) "2018-04-06 14:30:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
$date->tz('CEST');
var_dump($date);
//{ ["date"]=> string(26) "2018-04-06 15:30:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(4) "CEST" }
答案 0 :(得分:0)
问题是sleep
不是PHP中支持的时区,因此可以展示"undefined behaviour"。我怀疑它被解释为public class TokenRequest
{
public PostMe PostMe { get; set; }
public TokenRequest()
{
PostMe = new PostMe()
{
Name = "ABC ABC",
ManagementId = "ABC ABC",
ProxyUrl = ABC,
SourceFilename = ABC,
}; ;
}
public TokenRequest(PostMe postMe)
{
PostMe = postMe;
}
public static string TokenGenerate()
{
var client = new RestClient("any url ");
var request = new RestRequest(Method.POST);
// I want change the value of this PostMe properties for few test cases. since it's a executed under"BaseTest" and called before any test so I am not sure how to change these properties "Name, ProxyUrl etc" according to test.
var postMe = PostMe;
}
}
,即UTC + 1。
如果您使用特定的地理标识符,例如CEST
,则应显示正确的结果(即距离UTC + 2小时)。尝试:
CET