Files
finance/app/Http/Controllers/TimeDateController.php
T
Ümit Tunç 32119b6911 Add TimeDateController for server time and date API endpoints</message>
<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.
2025-01-20 22:43:52 +03:00

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')]);
}
}