.claude/skills/klytos-time/SKILL.md
Guide for working with dates, times, and timezones in Klytos CMS. Use when formatting dates, converting timezones, scheduling actions with timestamps, displaying local time, working with UTC storage, building timezone selectors, or using any klytos_date/klytos_gmdate/klytos_timezone functions.
npx skillsauth add joseconti/klytos klytos-timeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Store in UTC, display in local.
Europe/Madrid) — DST is handled automatically.DateTimeImmutable — no accidental mutation.| File | Purpose |
|------|---------|
| installer/core/timezone-cache.php | Internal cache class for the resolved DateTimeZone |
| installer/core/helpers-time.php | All klytos_* time functions |
| installer/core/helpers.php | Helpers::now() delegates to klytos_now_utc() |
Both are loaded in app.php boot sequence, before plugins.
// As DateTimeZone object (cached per-request)
$tz = klytos_timezone();
// → DateTimeZone('Europe/Madrid')
// As IANA string
$tzString = klytos_timezone_string();
// → 'Europe/Madrid'
// Current UTC offset in seconds (DST-aware)
$offset = klytos_timezone_offset();
// → 7200 (UTC+2 in summer)
The timezone is read from klytos_config('timezone'). Falls back to 'UTC' if missing or invalid.
// Reset the in-process cache so new value is picked up
klytos_timezone_reset_cache();
// ISO 8601 UTC — use this for ALL stored timestamps
$now = klytos_now_utc();
// → '2026-04-04T17:20:00+00:00'
$nowLocal = klytos_now_local();
// → '2026-04-04T19:20:00+02:00' (Europe/Madrid in summer)
$ts = klytos_time();
// → 1775063400
// Plugins can override the clock for testing:
klytos_add_filter('time.now', fn() => strtotime('2026-01-01'));
// Format current time in UTC
$date = klytos_gmdate( 'Y-m-d' );
// → '2026-04-04'
$id = klytos_gmdate( 'Ymd-His' );
// → '20260404-172000'
// Format a specific Unix timestamp in UTC
$formatted = klytos_gmdate( 'Y-m-d H:i:s', $timestamp );
Use klytos_gmdate() instead of bare date() or gmdate().
// Format current time in site's timezone
$localDate = klytos_date( 'Y-m-d H:i:s' );
// → '2026-04-04 19:20:00'
// Format a specific Unix timestamp in local time
$localFormatted = klytos_date( 'Y-m-d H:i', $timestamp );
// Converts UTC ISO string to local formatted display
$display = klytos_format_datetime( '2026-04-04T17:20:00+00:00', 'Y-m-d H:i' );
// → '2026-04-04 19:20' (in Europe/Madrid)
// Default format is 'Y-m-d H:i:s'
$display = klytos_format_datetime( $page['created_at'] );
$local = klytos_utc_to_local( '2026-04-04T17:20:00+00:00' );
// → '2026-04-04T19:20:00+02:00'
// With custom output format
$local = klytos_utc_to_local( '2026-04-04T17:20:00+00:00', 'Y-m-d H:i:s' );
// → '2026-04-04 19:20:00'
$utc = klytos_local_to_utc( '2026-04-04 19:20:00' );
// → '2026-04-04T17:20:00+00:00'
$ts = klytos_datetime_to_timestamp( '2026-04-04T17:20:00+00:00' );
// → 1775063400
$iso = klytos_timestamp_to_datetime( 1775063400 );
// → '2026-04-04T17:20:00+00:00'
For building timezone selectors:
$timezones = klytos_timezone_list();
// Returns grouped array:
// [
// 'Africa' => [
// ['id' => 'Africa/Abidjan', 'label' => 'Abidjan (UTC+00:00)', 'offset' => '+00:00'],
// ...
// ],
// 'America' => [...],
// 'Europe' => [
// ['id' => 'Europe/Madrid', 'label' => 'Madrid (UTC+02:00)', 'offset' => '+02:00'],
// ...
// ],
// 'UTC' => [...]
// ]
Continents are sorted alphabetically with UTC last. Entries within each group are sorted alphabetically. Offsets reflect the current DST state.
Filterable via time.timezone_list.
$record = [
'created_at' => klytos_now_utc(), // Always UTC
'updated_at' => klytos_now_utc(),
];
// "Run in 1 hour" — use Unix timestamps
$timestamp = klytos_time() + 3600;
klytos_schedule_single_action( $timestamp, 'my.hook' );
// The scheduler stores it as UTC ISO:
// klytos_timestamp_to_datetime( $timestamp )
$page = klytos_get_page( 'about' );
$displayDate = klytos_format_datetime( $page['created_at'], 'd/m/Y H:i' );
// → '04/04/2026 19:20' (local time)
$cutoff = klytos_gmdate( 'c', strtotime("-{$retentionDays} days") );
$entryId = klytos_gmdate( 'Ymd-His' ) . '-' . Helpers::randomHex(4);
// → '20260404-172000-a1b2c3d4'
date() or gmdate() — always use klytos_gmdate() or klytos_date().date('c', $ts) — use klytos_timestamp_to_datetime( $ts ).klytos_now_utc() for all persisted timestamps.klytos_format_datetime(), klytos_date(), or klytos_utc_to_local().Europe/Madrid), never manual offsets.| Hook | Type | Purpose |
|------|------|---------|
| time.now | Filter | Override the Unix timestamp returned by klytos_time() |
| time.timezone_list | Filter | Customize the timezone list for admin UI |
| Function | Returns | Purpose |
|----------|---------|---------|
| klytos_timezone() | DateTimeZone | Site's timezone object (cached) |
| klytos_timezone_string() | string | IANA timezone string |
| klytos_timezone_offset() | int | UTC offset in seconds (DST-aware) |
| klytos_timezone_reset_cache() | void | Clear timezone cache after config change |
| klytos_now_utc() | string | Current UTC time as ISO 8601 |
| klytos_now_local() | string | Current local time as ISO 8601 |
| klytos_time() | int | Current Unix timestamp (filterable) |
| klytos_gmdate( $fmt, $ts ) | string | Format in UTC |
| klytos_date( $fmt, $ts ) | string | Format in local timezone |
| klytos_format_datetime( $iso, $fmt ) | string | Format ISO string for local display |
| klytos_utc_to_local( $utc, $fmt ) | string | Convert UTC string to local |
| klytos_local_to_utc( $local, $fmt ) | string | Convert local string to UTC |
| klytos_datetime_to_timestamp( $dt ) | int | ISO/MySQL string to Unix timestamp |
| klytos_timestamp_to_datetime( $ts ) | string | Unix timestamp to ISO 8601 UTC |
| klytos_timezone_list() | array | Grouped IANA timezones for UI selectors |
tools
Guide for developing and extending the Klytos web terminal. Use when modifying terminal commands, adding terminal commands from plugins, fixing terminal bugs, extending the pseudo-terminal, working with TerminalExecutor class, registering custom permissions, adding custom category labels, or managing terminal UI and security.
development
--- name: klytos-site-builder description: Guide for building a complete website from scratch with Klytos CMS. Use when creating a new site, configuring a site after installation, setting up design/content/SEO/navigation, or when the user pastes the post-install prompt. Covers 9 phases: discovery, design reference, global config, theme, content structure, templates, content creation, additional features, and launch. --- # Klytos Site Builder ## Overview The Site Builder is a conversational AI
development
Use when creating or editing page content in Klytos CMS. Ensures every page has proper SEO structure, HTML semantics, meta tags, structured data, accessibility for maximum search engine visibility. Apply when writing page titles, descriptions, content, headings, images, internal links, JSON-LD schema, or following the SEO checklist before publishing pages.
development
Guide for SEO, sitemap.xml, llms.txt, and search engine and AI indexing in Klytos CMS. Use when asking about SEO, sitemap, robots.txt, llms.txt, meta tags, Open Graph, structured data, search engine optimization, AI indexing, page indexing, canonical URLs, hreflang tags, JSON-LD schema, or the build engine SEO process.