32119b6911
<message> - Introduced TimeDateController with two new endpoints: `/server-time` and `/server-date`. - Implemented methods to return the current server time and date in JSON format. - Enhanced API functionality by providing easy access to server time and date information.
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
/**
|
|
* @OA\Info(title="Time and Date API", version="1.0.0")
|
|
*/
|
|
class TimeDateController extends Controller
|
|
{
|
|
/**
|
|
* Get the current server time.
|
|
*
|
|
* @OA\Get(
|
|
* path="/server-time",
|
|
* summary="Get Server Time",
|
|
* @OA\Response(
|
|
* response=200,
|
|
* description="Successful response",
|
|
* @OA\JsonContent(
|
|
* @OA\Property(property="server_time", type="string", example="14:30:00")
|
|
* )
|
|
* )
|
|
* )
|
|
*
|
|
* @return JsonResponse
|
|
*/
|
|
public function getServerTime(): JsonResponse
|
|
{
|
|
return response()->json(['server_time' => date('H:i:s')]);
|
|
}
|
|
|
|
/**
|
|
* Get the current server date.
|
|
*
|
|
* @OA\Get(
|
|
* path="/server-date",
|
|
* summary="Get Server Date",
|
|
* @OA\Response(
|
|
* response=200,
|
|
* description="Successful response",
|
|
* @OA\JsonContent(
|
|
* @OA\Property(property="server_date", type="string", example="2023-10-01")
|
|
* )
|
|
* )
|
|
* )
|
|
*
|
|
* @return JsonResponse
|
|
*/
|
|
public function getServerDate(): JsonResponse
|
|
{
|
|
return response()->json(['server_date' => date('Y-m-d')]);
|
|
}
|
|
}
|