APIUSB / OpenAPI / 获取当前时间

获取当前时间

接口描述: 获取时间,日期、年份、星期等

HTTP/HTTPS
请求协议
GET/POST
请求方式
UTF-8
编码格式
JSON
返回格式

接口参数

参数名字类型是否必须默认值其他说明
access_token字符串可选访问令牌,仅当开启签名验证时需要传递,生成令牌可使用App.Auth.ApplyToken接口

返回字段

返回结果类型说明
ret整型状态码,200表示成功,4xx表示客户端非法请求,5xx表示服务器错误
data对象或混合类型业务数据,由各自接口指定,通常为对象
data.timestamp 时间戳,例如:1564622918integer
data.00:00:00string datetime 日期时间,例如:2019-08-01
data.日期,例如:2019-08-01string date
data.中文日期,月份和天前面有0,例如:2019年08月01日string date_md_zh
data.中文日期,月份和天前面没有0,例如:2019年8月1日string date_Nj_zh
data.time_H 字符串时间,24 小时格式,例如:18:00:00
data.时间,12string time_h 小时格式,例如:06:00:00
data.日,月份中的第几天,有前导零的string day_d 2 位数字,01 到 31
data.日,月份中的第几天,没有前导零,1string day_j 到 31
data.日,星期中的第几天,1(表示星期一)到string day_N 7(表示星期天)
data.日,年份中的第几天,0string day_z 到 365
data.星期,年份中的第几周,每周从星期一开始,例如:42(当年的第string week_W 42 周)
data.到string month_n 月,数字表示的月份,没有前导零,112
data.月,一月到十二月string month_n_zh
data.年string year_Y 4 位数字完整表示的年份,例如:1999 或 2003
data.小时string hour_H 24 小时格式,有前导零,00 到 23
data.前导零的分钟数,00string minute_i 分钟到 59
data.有前导零,00string second_s 秒数到 59
msg字符串提示信息,失败时的错误提示

在线测试   

参数是否必须
service 必须
access_token 可选

客户端请求示例

{
  "ret": 200,
  "data": {
    "timestamp": 1593743197,
    "datetime": "2020-07-03 10:26:37",
    "date": "2020-07-03",
    "date_md_zh": "2020年7月3日",
    "time_H": "10:26:37",
    "time_h": "10:26:37",
    "day_d": "03",
    "day_N": "5",
    "day_z": "184",
    "week_W": "27",
    "month_m": "07",
    "month_n": "7",
    "year_Y": "2020",
    "hour_g": "10",
    "hour_G": "10",
    "hour_h": "10",
    "hour_H": "10",
    "minute_i": "26",
    "second_s": "37",
    "day_N_zh": "星期五",
    "month_n_zh": "七月"
  },
  "msg": ""
}
curl https://api.apiusb.com/api/app?s=App.DateConvert.Curtime&username=PhalApi
{
  "ret": 200,
  "data": {
    "timestamp": 1593743197,
    "datetime": "2020-07-03 10:26:37",
    "date": "2020-07-03",
    "date_md_zh": "2020年7月3日",
    "time_H": "10:26:37",
    "time_h": "10:26:37",
    "day_d": "03",
    "day_N": "5",
    "day_z": "184",
    "week_W": "27",
    "month_m": "07",
    "month_n": "7",
    "year_Y": "2020",
    "hour_g": "10",
    "hour_G": "10",
    "hour_h": "10",
    "hour_H": "10",
    "minute_i": "26",
    "second_s": "37",
    "day_N_zh": "星期五",
    "month_n_zh": "七月"
  },
  "msg": ""
}

$.ajax({
  url: "https://api.apiusb.com/api/app",
  data: {s: "App.DateConvert.Curtime"},
  dataType: 'json',
  success: function (response, status, xhr) {
    console.log(response);
  }
});
<?php
require_once dirname(__FILE__) . '/PhalApiClient.php';

$client = PhalApiClient::create()
    ->withHost('https://api.apiusb.com/api/app');$rs = $client->reset()
->withService('App.DateConvert.Curtime')
->withTimeout(3000)
->request();

// ret状态码,200表示成功
var_dump($rs->getRet());
// 业务数据
var_dump($rs->getData());
// 提示信息
var_dump($rs->getMsg());
#-*- coding:utf-8 -*-
import PhalApiClient

result = PhalApiClient.PhalApiClient('https://api.apiusb.com/api/app', 'App.DateConvert.Curtimex', {}, 3)
//FullscreenActivity.java
import net.phalapi.sdk.*;    /**
     * 网络操作相关的子线程
     */
    Runnable networkTask = new Runnable() {

        @Override
        public void run() {
            // TODO
            // 在这里进行 http request.网络请求相关操作

        	PhalApiClient client = PhalApiClient.create()
	       			    .withHost("https://api.apiusb.com/api/app");

	       	PhalApiClientResponse response = client
	       			    .withService("App.DateConvert.Curtime")
	       			    .withTimeout(3000)
	       			    .request();

	   		String content = "";
	   		content += "ret=" + response.getRet() + "\n";
	   		if (response.getRet() == 200) {
				try {
					JSONObject data = new JSONObject(response.getData());
					content += "data.title=" + data.getString("title") + "\n";
					content += "data.content=" + data.getString("content") + "\n";
					content += "data.version=" + data.getString("version") + "\n";
				} catch (JSONException ex) {

				}
	   		}
			content += "msg=" + response.getMsg() + "\n";

			Log.v("[PhalApiClientResponse]", content);


            Message msg = new Message();
            Bundle data = new Bundle();
            data.putString("value", content);
            msg.setData(data);
            handler.sendMessage(msg);
        }
    };
PhalApiClientResponse response = PhalApiClient.create()
  .withHost("https://api.apiusb.com/api/app")
  .withService("App.DateConvert.Curtime")
  .withTimeout(3000)
  .request();

Log.v("response ret", response.ret + "");
Log.v("response data", response.data);
Log.v("response msg", response.msg);
#import "AFNPhalApiClient.h"// POST
NSDictionary *params = @{};

// Call AFNPhalApiClient
[[[[[AFNPhalApiClient sharedClient] withHost:@"https://api.apiusb.com/api/app"] withService:@"App.DateConvert.Curtime"] withParams:params] requestWithFormDataBlock:^(id formData) {
	//
    [formData appendPartWithFileData:UIImageJPEGRepresentation([UIImage imageNamed:@"head.JPG"], 1) name:@"file" fileName:@"image.jpg" mimeType:@"image/jpeg"];
} completeBlock:^(id resultObject) {
    PALog(@"resultObject: %@", resultObject);
} failureBlock:^(NSError *error) {
    PALog(@"error: %@", error);
}];

// Print url
PALog(@"total url: %@", [[AFNPhalApiClient sharedClient] printTotalUrlStr]);

错误列表

错误状态码错误描述信息
400ret=400,客户端参数错误或非法请求
404表示接口服务不存在
406ret=406,access_token令牌校验不通过
407ret=407,app_key权限不足,或未知应用
408ret=408,当前用户禁止使用,或用户未登录
500表示服务端内部错误

本文档生成时间:2024-04-16 22:28:45