thinkphp에서 API 인터페이스 클라이언트 및 서버의 시간 일관성 솔루션 알아보기

thinkphp에서 API 인터페이스 클라이언트 및 서버의 시간 일관성 솔루션 알아보기

배경

클라이언트 (앱, 애플릿)와 서버의 시간이 일치하지 않습니다.

해결책

1. 새 시간 컨트롤러 만들기

<?php

namespace app\api\controller;

use think\Controller;


class Time extends Controller
{
    
    

    public function index()
    {
    
    
        $data = array(
            'time' => time(),
        );
        return show(0, '', $data);
    }    
}

2. 경로 수정


//get方式
Route::get('time', 'api/time/index');

3. 우편 배달원이 가져 오기 요청을 보냅니다.

여기에 사진 설명 삽입

추천

출처blog.csdn.net/guo_qiangqiang/article/details/112142045