class: JordanPrice\Toolbox\Tools\Time\TimeTool
env vars: None
source: GitHub

Prism Integration

use JordanPrice\Toolbox\Tools\Time\TimeTool;
use EchoLabs\Prism\Prism;
use EchoLabs\Prism\Enums\Provider;
use EchoLabs\Prism\Enums\ToolChoice;

$timeTool = new TimeTool();

$prism = Prism::text()
    ->using(Provider::Anthropic, 'claude-3-5-sonnet-latest')
    ->withPrompt('What time is it in New York?')
    ->withTools([$timeTool])  // Pass the tool instance
    ->toolChoice(ToolChoice::Any);

$response = $prism->generate();

Publish

Optionally, you can publish the configuration file to make modifications:
# Publish just this tool
php artisan toolbox:publish time

# Or publish all tools
php artisan toolbox:publish --all

Methods

__invoke

Get current time in specified timezone and format.
public function __invoke(string $timezone = 'UTC', string $format = 'full'): string

Parameters

  • timezone (string): Target timezone (e.g., America/Chicago, UTC). Default is local timezone.
  • format (string): Output format (full, short, etc.). Default is full.

Returns

  • string: Formatted time in the specified timezone