跳转到主要内容

查询服务器时间

查询当前服务器时间信息。 所有服务器时间均以 UTC 标准提供。

调用信息

ServerTime(PlayNANOODelegate callback) {}

调用详细信息

参数说明类型
callback通信结果PlayNANOODelegate

源代码

using PlayNANOO;

public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;

void Awake()
{
plugin = Plugin.GetInstance();

plugin.ServerTime((state, message, rawData, dictionary) => {
if(state.Equals(Configure.PN_API_STATE_SUCCESS)) {
Debug.Log(dictionary["timezone"]);
Debug.Log(dictionary["timestamp"]);
Debug.Log(dictionary["ISO_8601_date"]);
Debug.Log(dictionary["date"]);
Debug.Log(dictionary["year"]);
Debug.Log(dictionary["month"]);
Debug.Log(dictionary["day"]);
Debug.Log(dictionary["hour"]);
Debug.Log(dictionary["minute"]);
Debug.Log(dictionary["second"]);
} else {
Debug.Log("Fail");
}
});
}
}

通信结果

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"code" : 200,
"message" : 0,
"value" : {
{
"timezone" : "String",
"timestamp" : "Integer",
"ISO_8601_date" : "String",
"date" : "String",
"year" : "String",
"month" : "String",
"day" : "String",
"hour" : "String",
"minute" : "String",
"second" : "String"
}
}
}

通信结果详细信息

数据键说明类型
timezone时区信息string
timestamp从1970年1月1日0时0分0秒至今的秒数string
ISO_8601_dateISO 8601 标准格式string
date默认日期格式string
year年份(4位数)string
month月份(含0补位,2位数)string
day日期(含0补位,2位数)string
hour小时(含0补位,2位数)string
minute分钟(含0补位,2位数)string
second秒(含0补位,2位数)string